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 error when adding revisions to existing APIs #22380

Closed
wants to merge 8 commits into from

Conversation

kevjallen
Copy link

fix for the issues described here:
#12720
#18093

sample terraform code:

data "azurerm_api_management" "service" {
  name                = "my-awesome-apim-service"
  resource_group_name = "my-awesome-apim-resource-group"
}

data "azurerm_api_management_api" "source_api" {
  api_management_name = data.azurerm_api_management.service.name
  resource_group_name = data.azurerm_api_management.service.resource_group_name

  name = "my-awesome-apim-api"

  revision = "1"
}

resource "azurerm_api_management_api" "revision" {
  api_management_name = data.azurerm_api_management.service.name
  resource_group_name = data.azurerm_api_management.service.resource_group_name

  name         = data.azurerm_api_management_api.source_api.name
  description  = data.azurerm_api_management_api.source_api.description
  display_name = data.azurerm_api_management_api.source_api.display_name
  path         = data.azurerm_api_management_api.source_api.path
  protocols    = data.azurerm_api_management_api.source_api.protocols

  revision = "2"

  import {
    content_format = "openapi"
    content_value = file("my-awesome-openapi-spec.yml")
  }
}

trying to create a revision of an existing API using the above code currently results in this error:

Future#WaitForCompletion: the number of retries has been exceeded: StatusCode=400 -- Original Error: Code="ValidationError" Message="Can't change property ApiVersion for non-current revision "

@kevjallen
Copy link
Author

@katbyte

I noticed the checks were cancelled for this PR, when would be a good time to have them run?

Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

@kevjallen Thanks for this PR. I've re-triggered the checks, they probably failed due to an Actions outage.

I'm attempting to check out your changes locally to review them, but it looks like the source branch has patched some of the imports? I'm not sure why these aren't showing up in the PR diff, but I'm not confident to merge this - would you be able to commit these changes to a separate branch rather than your fork's main branch, and re-open the PR from that separate branch? Ideally if you can rather use a personal fork rather than an organization fork, this will help us to potentially push changes to the PR branch as needed. Thanks!

Screenshot 2023-07-18 at 19 18 26

@kevjallen
Copy link
Author

kevjallen commented Jul 19, 2023

@manicminer Hi, thanks for the response!

The repo I am trying to merge from is called nexient-llc/terraform-provider-azurerm-apim-revisions (the one you have pictured / linked is a different repo in the same organization). The source repo for this PR does not have the patched imports you described, and has no other changes other than those relevant to this issue.

Please let me know if that is acceptable, thanks

@manicminer
Copy link
Contributor

Aha, so it is! It'd be great if GitHub surfaced this detail without making you click through on the diff page 😅

I'll take another look today, thanks!

Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

@kevjallen This is mostly looking good. Unfortunately, changing the ID means that we'll need a state migration here.

This involves bumping the SchemaVersion and configuring a StateUpgrader for the Resource struct instance. You can find straightforward examples of this in the various record resources in the dns package, and a reference guide in the plugin SDK documentation.

Please reach out if you need any further pointers!

@kevjallen
Copy link
Author

@manicminer Please review the state migration when you have a moment, thanks!

@kevjallen
Copy link
Author

@manicminer @stephybun

I believe this is ready for another review, the changes from the SDK migration were incorporated here

@stephybun
Copy link
Member

Apologies for the delayed response @kevjallen.

We've been fixing some broken APIM state-migrations that recently got into the provider. In the process of this we've opened #23031 which incorporates your changes to address one of the fixes we believe is required to bring these into a workable state again. Before merging #23031 we need an internal discussion to resolve concerns we have around a ; in the resource ID since this could be problematic.

State-migrations become a permanent component of a resource and need to be treated with appropriate caution. For this reason, as well as to avoid duplicate PRs, I'm going to close this PR in favour of #23031.

Thank you so much for your time and effort on this!

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 May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants