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

Fix cross-subscription Gallery builds that use are using a virtual machine source #404

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

JenGoldstrich
Copy link
Contributor

@JenGoldstrich JenGoldstrich commented Apr 11, 2024

Azure shipped a change in the last month adding a new field to the gallery storage profile source, `source.VirtualMachineId', this ID is only in newer versions of the API, but we are still seeing a report of the below error occuring when building cross-subscription, the error pretty straight forwardly points to the solution but IMO this is still a pretty unusual breaking change as this occurs even in previous plugin versions, it is not based on any updates we have done, but rather an Azure API change.

Before:

When building across two subscriptions (use client_id/client_secret for this and specify both subscription IDs)

Build 'azure-arm.autogenerated_1' errored after 3 minutes 4 seconds: performing CreateOrUpdate: unexpected status 400 (400 Bad Request) with error: InvalidParameter: The source VM '/subscriptions/sub1/resourceGroups/pkr-Resource-Group-q9eltm1tty/providers/Microsoft.Compute/virtualMachines/pkrvmq9eltm1tty' is a cross subscription source for the galleryImageVersion created in subscription 'sub2'. Please retry the call by specifying the VM id in 'galleryImageVersion.properties.storageProfile.source.virtualMachineId' instead. See https://aka.ms/acgsecurityupdates for more details.

After:

The build succeeds.

Closes #403

@JenGoldstrich JenGoldstrich changed the title Send VM Source IDs using new field Send VM Source IDs using new field to fix cross-SIG VM-backed SIG builds Apr 11, 2024
@JenGoldstrich JenGoldstrich changed the title Send VM Source IDs using new field to fix cross-SIG VM-backed SIG builds Send VM Source IDs using new field to fix cross-Subscription VM-backed Gallery builds Apr 11, 2024
@JenGoldstrich JenGoldstrich changed the title Send VM Source IDs using new field to fix cross-Subscription VM-backed Gallery builds Fix cross-subscription Gallery builds that use a virtual machine as a base Apr 11, 2024
@JenGoldstrich JenGoldstrich changed the title Fix cross-subscription Gallery builds that use a virtual machine as a base Fix cross-subscription Gallery builds that use are using a virtual machine source Apr 11, 2024
@@ -126,7 +126,7 @@ func (c *Config) setCloudEnvironment() error {

environmentContext, cancel := context.WithTimeout(context.Background(), time.Minute*3)
defer cancel()
env, err := environments.FromEndpoint(environmentContext, c.MetadataHost, c.CloudEnvironmentName)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CloudEnvironmentName was removed from the FromEndpoint function in a recent update to go-azure-sdk, this was used as a fall back mechanism if metadata host is not set, we default set that to Azure Public, but below on line 132 we fall back to calling the FromName method to get the environment, so this should not be a breaking change.

@JenGoldstrich JenGoldstrich marked this pull request as ready for review April 11, 2024 21:56
@JenGoldstrich JenGoldstrich requested a review from a team as a code owner April 11, 2024 21:56
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.

LGTM!

@JenGoldstrich JenGoldstrich merged commit e82be53 into main Apr 16, 2024
12 checks passed
@JenGoldstrich JenGoldstrich deleted the fix_acg_source_id branch April 16, 2024 14:59
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.

Cross Subscription Image Builds Failing - newer resource-manager version solves issue
2 participants