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

Upgrade Api Management from 2020-12-01 to 2021-08-01 #14312

Merged
merged 9 commits into from Dec 14, 2021

Conversation

oWretch
Copy link
Contributor

@oWretch oWretch commented Nov 24, 2021

Microsoft added a large amount of functionality in 2021-01-01-preview for API Management. This PR is to move us to the latest stable API release, which will allow for adding functionality to resolved issues such as #12021 and #13445. It updates all the constants which were renamed.

The only potential regression is that Sample is no longer a property in the OperationRepresentation schema. It has been replaced with a map of Examples. I can update the schema, but I'm not sure how to deal with the value property of the ParameterExampleContract. If someone can help me with this, I'll push the code for the Examples.

My plan is to uplift the features in separate PRs.

@aristosvo
Copy link
Collaborator

aristosvo commented Nov 24, 2021

@oWretch Just a small comment based on previous work done by others, we'd need to check backward compatibility with resources provisioned with the old API version. This was a problem previously, not sure about now.

@oWretch
Copy link
Contributor Author

oWretch commented Nov 24, 2021

What I currently see with APIM in our environment is if you deploy a core component of a resource that requires a new API version you cannot edit the resource with an older API version. That matches my reading of the reported issue above (#12566 (comment)).

We have manually updated an APIM instance to be deployed in zones. Because this is a feature that requires the 2021-01-01-preview API version, when we run terraform and attempt to change the azurerm_api_management resource, it errors because it needs the newer API version. All other resources which are provisioned on this APIM (products, APIs, operations, etc) all work correctly with the older API version. This matches Jeffrey's comment in the issue above.

I'll run more tests with the updated provider tomorrow and make sure our non-zonal APIM instances which are managed on the old API version are still manageable on the new.

@favoretti
Copy link
Collaborator

Hi there and thank you for adding this. One small remark from my side - this change not only brings APIM API upgrade, but a complete SDK upgrade, which is... somewhat more involved. Whereas it might seem that same versions of packages should stay the same between different SDK versions, in practice it's now always the case.

@oWretch
Copy link
Contributor Author

oWretch commented Nov 24, 2021

Agreed @favoretti.

We need the SDK upgrade to get the API version. And there was a recent commit to bring the SDK up to v59.2.0, so we are not making a large jump in this PR.

@oWretch
Copy link
Contributor Author

oWretch commented Nov 24, 2021

I've reviewed our existing APIM instances that were created with the previous API Version, and they are all reading correctly with the updated API. While not a test of all provider functionality, it indicates that the versions are backwards compatible for existing services.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @oWretch, left a comment inline on what to do with the sample property

@oWretch oWretch requested a review from katbyte November 30, 2021 22:34
@oWretch oWretch force-pushed the f/apim-2021-08-01-update branch 2 times, most recently from 2900b90 to aa903fa Compare December 1, 2021 00:42
@katbyte
Copy link
Collaborator

katbyte commented Dec 9, 2021

Have a panic in the tests @oWretch

Test ended in panic.

------- Stdout: -------
=== RUN   TestAccApiManagementApiOperation_representations
=== PAUSE TestAccApiManagementApiOperation_representations
=== CONT  TestAccApiManagementApiOperation_representations

------- Stderr: -------
panic: interface conversion: interface {} is nil, not string

goroutine 524 [running]:
github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/schemaz.ExpandApiManagementOperationParameterExampleContract({0xc001f0af88, 0x1, 0x600d7d2})
	/opt/teamcity-agent/work/5e6516bb4d10eb66/internal/services/apimanagement/schemaz/api_management.go:382 +0x465
github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement/schemaz.ExpandApiManagementOperationRepresentation(0x60376c7, {0xc002957548, 0x18}, {0xc0002e31b0, 0x1, 0xc001c33458})
	/opt/teamcity-agent/work/5e6516bb4d10eb66/internal/services/apimanagement/schemaz/api_management.go:146 +0x4e5
github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement.expandApiManagementOperationRequestContract(0x67e4200, {0x6011404, 0x7}, {0xc0002e3140, 0xc0045709f0, 0x0})

@oWretch
Copy link
Contributor Author

oWretch commented Dec 10, 2021

ApiOperation tests all now passing

==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test -v ./internal/services/apimanagement -run=TestAccApiManagementApiOperation_ -timeout 8h -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccApiManagementApiOperation_basic
=== PAUSE TestAccApiManagementApiOperation_basic
=== RUN   TestAccApiManagementApiOperation_requiresImport
=== PAUSE TestAccApiManagementApiOperation_requiresImport
=== RUN   TestAccApiManagementApiOperation_customMethod
=== PAUSE TestAccApiManagementApiOperation_customMethod
=== RUN   TestAccApiManagementApiOperation_headers
=== PAUSE TestAccApiManagementApiOperation_headers
=== RUN   TestAccApiManagementApiOperation_requestRepresentations
=== PAUSE TestAccApiManagementApiOperation_requestRepresentations
=== RUN   TestAccApiManagementApiOperation_representations
=== PAUSE TestAccApiManagementApiOperation_representations
=== CONT  TestAccApiManagementApiOperation_basic
=== CONT  TestAccApiManagementApiOperation_headers
=== CONT  TestAccApiManagementApiOperation_customMethod
=== CONT  TestAccApiManagementApiOperation_representations
=== CONT  TestAccApiManagementApiOperation_requiresImport
=== CONT  TestAccApiManagementApiOperation_requestRepresentations
--- PASS: TestAccApiManagementApiOperation_basic (370.01s)
--- PASS: TestAccApiManagementApiOperation_customMethod (370.01s)
--- PASS: TestAccApiManagementApiOperation_headers (373.03s)
--- PASS: TestAccApiManagementApiOperation_requiresImport (392.49s)
--- PASS: TestAccApiManagementApiOperation_requestRepresentations (430.98s)
--- PASS: TestAccApiManagementApiOperation_representations (439.74s)
PASS
ok  	github.com/hashicorp/terraform-provider-azurerm/internal/services/apimanagement	441.216s

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @oWretch! LGTM 🚀

@katbyte katbyte merged commit 5b973d6 into hashicorp:main Dec 14, 2021
@github-actions github-actions bot added this to the v2.90.0 milestone Dec 14, 2021
katbyte added a commit that referenced this pull request Dec 14, 2021
@github-actions
Copy link

This functionality has been released in v2.90.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants