-
Notifications
You must be signed in to change notification settings - Fork 80
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
ARM: Improve validation of direct_shared_gallery_image_id
and community_gallery_image_id
and make include Microsoft links in plugin docs
#424
Comments
direct_shared_gallery_image_id
and community_gallery_image_id
fail during ARM template deployment
Hey @sabuncumurat, So the issue you're running here is that Direct Shared Image Gallery's and Community Gallery's are distinct types of shared images which can not be referenced using the Azure resource ID. A Direct Shared Image Gallery is a preview feature https://learn.microsoft.com/en-us/azure/virtual-machines/share-gallery-direct?tabs=portaldirect that shares images across tenants and subscriptions, as such its ID would not be a standard Azure resource ID. You can find examples of each of these IDs here https://developer.hashicorp.com/packer/integrations/hashicorp/azure/latest/components/builder/arm but for direct shared galleries it would look something like this A community gallery would also have a different resource ID and would not be referenced by the subscription ID https://learn.microsoft.com/en-us/azure/virtual-machines/share-gallery-community?tabs=cli and is shared with the wider Azure community I believe However there is also some inconsistent logic in the code base around this feature, and some poorly defined docs, so here's a few ways I will plan to address this 1.) We shouldn't allow setting a subscription id or resource group name in the packer-plugin-azure/builder/azure/arm/template_factory.go Lines 175 to 189 in 1b209f5
2.) We should print the source name of the direct or community ID gallery, rather than printing an invalid source name in the step_get_source_image_name 3.) We should update the docs to point to the Microsoft docs that describe these features, and make it clearer than this is a different type of image. So that users can more clearly understand that these are different images than normal compute gallery image versions. With regards to your orphaned resources this is a bit tricky to diagnose without your full build logs, sometimes when VM Deployments fail Azure won't let the network resources be closed until the VM's nic reservation fully times out, which can lead to these resources, I can comment more on this if you |
direct_shared_gallery_image_id
and community_gallery_image_id
fail during ARM template deploymentdirect_shared_gallery_image_id
and community_gallery_image_id
and make include Microsoft links in plugin docs
@JenGoldstrich First off, thank you for your response. I reran the build to repro the orphaned-resources problem. The same set of resources were left behind (pip, nic and vnet). I am attaching the log file packerlog.txt: I will comment separately about the other points in your response. |
The cause of the orphaned resources is this error
Since the VM was never created we can't delete it, but Azure will refuse to delete the nic for 180 seconds later, which is far past our logic for retrying to delete resources, if you don't set a |
Thanks for the explanation. Based on your response I tried this: Unfortunately, I got this error:
I don't have a location specified in my template, so the above error makes no sense. I then removed Happy to report that worked, and a temporary RG was created and following the errors (from earlier) everything (pip, nic, and vnet) was deleted. (The delete took a really long time, and it was totally silent - there were no multiple 'trying...' attempt outputs.) Thank you sooo much for your guidance. Huge learning experience for me. One additional curiosity if I may: I searched both the packer main repo and this repo to look for the error string 'Specify either a location to create the resource group in or an existing build_resource_group_name, but not both' but came up empty-handed. Why is this? Thanks again. |
:] Of course, happy to help!
packer-plugin-azure/builder/azure/arm/config.go Lines 1298 to 1300 in 1b209f5
|
This issue was originally opened by @sabuncumurat in hashicorp/packer#13036 and has been migrated to this repository. The original issue description is below.
I have the following pkr.hcl file:
The above works and version 6.4.0 of the image in question is generated successfully from version 2.2.3, as intended. All good.
When I replace
image_name
andimage_version
in theshared_image_gallery
block with eithercommunity_gallery_image_id
ordirect_shared_gallery_image_id
, the image generation fails:PowerShell session error:
Please note that in the second line of the error above, the Id string after BadRequest is missing components after the galleries part.
If this is not a bug, what is the proper way to use an
image_id
in ashared_image_gallery
block?And a related question - when the above image build fails, three artifacts are left behind and not cleaned up:
I have to remove them manually.
I am under the impression that Packer is supposed to clean up even in case of an error. Is this really the case?
Thank you.
The text was updated successfully, but these errors were encountered: