Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use specific image versions directly for virtual machines #808

Closed
wants to merge 1 commit into from

Conversation

danielpanteleit
Copy link

@danielpanteleit danielpanteleit commented Apr 5, 2022

SUMMARY

Fixes #766

Currently we can't use the non-latest version of a virtual machine image. After PR #606 only the latest version for an image is fetched. For example I tried this image, which did not work:

"offer": "0001-com-ubuntu-server-focal"
"publisher": "Canonical"
"sku": "20_04-lts-gen2"
"version": "20.04.202203310"

This change will only fetch versions if we use the version "latest" and otherwise use the version as specified by the user.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

azure_rm_virtualmachine

for version in versions:
if version.name == self.image['version']:
return version
return versions[len(versions) - 1].name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If version is specified and cannot be obtained through the first one, the PR function is similar to #767. Thank you very much!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my changes the version lookup will only happen when "latest" is used. Otherwise the user specified version is used directly. I think it doesn't make much sense to get all versions of an image to check if the specified version is listed or not.

@Fred-sun Fred-sun added the duplicate This issue or pull request already exists label Apr 7, 2022
@Fred-sun
Copy link
Collaborator

Fred-sun commented Apr 7, 2022

@danielpanteleit If the version specified by the user does not exist or is unavailable in the region, no exception will be thrown!

@danielpanteleit
Copy link
Author

@Fred-sun Yes, there is no specific error message in the code, but there will still be a recognizable error message:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error creating or updating virtual machine test - (PlatformImageNotFound) The platform image 'Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:20.04.202203320' is not available. Verify that all fields in the storage profile are correct. For more details about storage profile information, please refer to https://aka.ms/storageprofile\nCode: PlatformImageNotFound\nMessage: The platform image 'Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:20.04.202203320' is not available. Verify that all fields in the storage profile are correct. For more details about storage profile information, please refer to https://aka.ms/storageprofile\nTarget: imageReference"}

Though I understand if you want a more readable error message.

@Fred-sun
Copy link
Collaborator

Fred-sun commented Apr 8, 2022

@danielpanteleit This is also ok, if the resource cannot be found when creating it, the API will report an error. But #767 is more in line with our code design logic. If not, an error is reported and the desired log reminder is printed. Thank you very much!

@Fred-sun
Copy link
Collaborator

@danielpanteleit I'm sorry, but we prefer to change #767 after internal discussion, which is in line with the code design. Thank you very much!

@Fred-sun Fred-sun closed this Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

azure_rm_virtualmachine loads only one image (-> top=1), therefore the "version" option does not work
2 participants