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

ARM: Show API errors when failing to validate existing resources and when deleting them. #423

Merged
merged 4 commits into from
Jun 13, 2024

Conversation

JenGoldstrich
Copy link
Contributor

@JenGoldstrich JenGoldstrich commented Jun 12, 2024

Currently when failing to fetch the destination SIG, or the resource group with managed images, or when trying to delete existing resources, we don't show the actual error from the API. For the get requests we just say its not found, even though the API gives us more specific information about what is not found. We should return those error messages to make it easier for users to diagnose issues with their builds

Before this PR for one of these error cases

packer build ~/azure-templates/hcl/sig-ubuntu.pkr.hcl
azure-arm.autogenerated_1: output will be in this color.

==> azure-arm.autogenerated_1: Running builder ...
    azure-arm.autogenerated_1: Creating Azure Resource Manager (ARM) client ...
    azure-arm.autogenerated_1: ARM Client successfully created
Build 'azure-arm.autogenerated_1' errored after 1 second 18 milliseconds: the Shared Gallery Image 'gallery' to which to publish the managed image version to does not exist in the resource group 'jenna' or does not contain managed image 'image'

==> Wait completed after 1 second 18 milliseconds

==> Some builds didn't complete successfully and had errors:
--> azure-arm.autogenerated_1: the Shared Gallery Image 'gallery' to which to publish the managed image version to does not exist in the resource group 'jenna' or does not contain managed image 'image'

==> Builds finished but no artifacts were created.

After

packer build ~/azure-templates/hcl/sig-ubuntu.pkr.hcl
azure-arm.autogenerated_1: output will be in this color.

==> azure-arm.autogenerated_1: Running builder ...
    azure-arm.autogenerated_1: Creating Azure Resource Manager (ARM) client ...
    azure-arm.autogenerated_1: ARM Client successfully created
Build 'azure-arm.autogenerated_1' errored after 1 second 858 milliseconds: failed to get image "image" from destination image gallery "gallery" in resource group "jenna": unexpected status 404 (404 Not Found) with error: ResourceGroupNotFound: Resource group 'jenna' could not be found.

==> Wait completed after 1 second 858 milliseconds

==> Some builds didn't complete successfully and had errors:
--> azure-arm.autogenerated_1: failed to get image "image" from destination image gallery "gallery" in resource group "jenna": unexpected status 404 (404 Not Found) with error: ResourceGroupNotFound: Resource group 'jenna' could not be found.

==> Builds finished but no artifacts were created.

After we clearly can tell that the resource group is missing

@JenGoldstrich JenGoldstrich changed the title ARM: Log builder errors when failing to fetch and delete parent and source resources ARM: Show API errors when failing to validate existing resources and when deleting them. Jun 12, 2024
…he builder

- Retrieving the resource group for managed images
- Retrieving the SIG image definition destination
- Deleting the existing SIG Image version
- Retrieving the Parent Shared Image Gallery
@JenGoldstrich JenGoldstrich force-pushed the show_actual_error_on_arm_builder_validation branch from 74e190a to 30d5f1e Compare June 12, 2024 23:34
@JenGoldstrich JenGoldstrich marked this pull request as ready for review June 12, 2024 23:44
@JenGoldstrich JenGoldstrich requested a review from a team as a code owner June 12, 2024 23:44
Copy link
Contributor

@sylviamoss sylviamoss left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏼

Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

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

Just left some nits, but aside from that LGTM

builder/azure/arm/builder.go Outdated Show resolved Hide resolved
builder/azure/arm/builder.go Outdated Show resolved Hide resolved
builder/azure/arm/builder.go Outdated Show resolved Hide resolved
@JenGoldstrich JenGoldstrich merged commit 2b89b16 into main Jun 13, 2024
11 of 12 checks passed
@JenGoldstrich JenGoldstrich deleted the show_actual_error_on_arm_builder_validation branch June 13, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants