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

Update to the newest version of hashicorp/go-azure-sdk #396

Merged
merged 2 commits into from
Apr 2, 2024

Conversation

JenGoldstrich
Copy link
Contributor

@JenGoldstrich JenGoldstrich commented Mar 26, 2024

This PR makes several changes to upgrade github.com/hashicorp/go-azure-sdk from version v0.20230523.1140858 to the newest version at the time of this PR v0.20240327.1161949, and to fully remove the deprecated Microsoft go-autorest library.

  1. Every request on the new SDK client layer requires a context with a deadline, otherwise requests fail with the following error the context used must have a deadline attached for polling purposes, but got no deadline, even if counter-intuitively the request would not use polling

  2. When the tenant ID is unset and not using CLI auth the plugin makes an unauthenticated HTTP request to the GetSubscriptions endpoint to fetch the tenant ID through the auth headers, the new SDK does not return these headers unless the auth object is correctly configured so now this is done with a regular http client

  3. The Chroot Builder used an autorest client to connect to the Azure IMDS, this has also been modified to use a regular http client, enabling the removal of auto rest

  4. The chroot builder has a long running bug Azure-chroot has issues with detecting environment information. Error is 'function "vm" not defined' #87 where we get an error that the vm template function is not defined unless setting 4 temporary values, this is due to an issue with the packer SDK wiping out this function when calling Decode, @lbajolet-hashicorp is investigating this issue further on the SDK end but to fix this on chroot this PR moves the function after Decode, so that is available in the builder. The vm function does not appear to be working at all currently, but this seems due to the SDK bug, and will be addressed in a follow up PR if not.

Closes #87
Unblocks #395

@JenGoldstrich JenGoldstrich changed the title Bump Go Azure SDK Update to the newest version of hashicorp/go-azure-sdk Mar 27, 2024
@JenGoldstrich JenGoldstrich force-pushed the bump_go_azure_sdk branch 3 times, most recently from cfe7219 to 5e0089e Compare March 27, 2024 21:31
@@ -50,12 +45,18 @@ type AzureClientSet interface {
var _ AzureClientSet = &azureClientSet{}

type azureClientSet struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While this client is in the common package it is only used by the chroot builder, the way I made this work with the new clients is a bit hacky, but I felt it wasn't worth a lot of time refactoring the chroot builder heavily as it makes up a very small percent of our usage.

@JenGoldstrich JenGoldstrich force-pushed the bump_go_azure_sdk branch 2 times, most recently from ea49404 to 4e24ebf Compare March 27, 2024 21:37
@@ -1,40 +1,36 @@
module github.com/hashicorp/packer-plugin-azure

go 1.19
go 1.21
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Is 1.21.8 a requirement for these changes or should we just always set to 1.21.N since this is technically the latest version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not at all, I just bumped us to 1.21 based on what was already set in the .go-version, these changes should work independent of go minor version.

@JenGoldstrich JenGoldstrich force-pushed the bump_go_azure_sdk branch 2 times, most recently from 06081ef to 47c605c Compare March 28, 2024 22:57
@JenGoldstrich JenGoldstrich marked this pull request as ready for review April 1, 2024 15:11
@JenGoldstrich JenGoldstrich requested a review from a team as a code owner April 1, 2024 15:11
GNUmakefile Outdated
dev: build
@mkdir -p ~/.packer.d/plugins/
@mv ${BINARY} ~/.packer.d/plugins/${BINARY}
dev:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why this is showing up as a change, when I checkout the makefile from main I don't see any changes either 🤔

➜  packer-plugin-azure git:(bump_go_azure_sdk) git checkout origin/main -- GNUmakefile
➜  packer-plugin-azure git:(bump_go_azure_sdk) gst
On branch bump_go_azure_sdk
nothing to commit, working tree clean

…ug, move metadata client off auto-rest, and handle unathenticated subscription call in custom http client
Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

This looks good to me. I appreciate the added context for the context.WithTimeout.

@JenGoldstrich JenGoldstrich merged commit d636271 into main Apr 2, 2024
12 checks passed
@JenGoldstrich JenGoldstrich deleted the bump_go_azure_sdk branch April 2, 2024 20:48
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.

Azure-chroot has issues with detecting environment information. Error is 'function "vm" not defined'
2 participants