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

Flaky creation of management groups: "The resource type 'operationResults/asyncOperation' could not be found in the namespace 'Microsoft.Management' for api version '2018-03-01-preview' #14558

Closed
Andrei-Predoiu opened this issue Dec 9, 2021 · 12 comments · Fixed by #14635
Labels
bug service/managed-apps upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR
Milestone

Comments

@Andrei-Predoiu
Copy link

Andrei-Predoiu commented Dec 9, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

terraform 1.1.0
azurerm 2.88.1
Bug is also observed on 2.87, untested on 2.80

Affected Resource(s)

azurerm_management_group

Terraform Configuration Files

resource "azurerm_management_group" "development_peered" {
  count                      = var.env == "Development" && var.peered == 1 ? 1 : 0
  display_name               = "${var.product}-${var.env}-${var.location}"
  parent_management_group_id = var.parent_management_group_id[2]
  subscription_ids           = [var.subscription_ids]
}

Debug Output

Panic Output

Expected Behaviour

The group should be created and the build should succeed.

Actual Behaviour

about 1 out of 5 times the plan application fails with the following error:

╷
│ Error: failed when waiting for creation of Management Group "4252ac91-509e-4f7d-9a90-507c11e7006a": Future#WaitForCompletion: the number of retries has been exceeded: StatusCode=404 -- Original Error: Code="InvalidResourceType" Message="The resource type 'operationResults/asyncOperation' could not be found in the namespace 'Microsoft.Management' for api version '2018-03-01-preview'. The supported api-versions are '2021-04-01,2020-10-01,2020-05-01,2020-02-01,2019-11-01,2018-03-01-beta'."
│ 
│   with module.management_group_for_spoke_and_rbac.azurerm_management_group.development_peered[0],
│   on ../modules/spoke_management_group/main.tf line 60, in resource "azurerm_management_group" "development_peered":
│   60: resource "azurerm_management_group" "development_peered" {
│ 
╵

Steps to Reproduce

  1. terraform apply

Important Factoids

We are running in westeurope
skip_provider_registration is not enabled

References

@Andrei-Predoiu
Copy link
Author

According to the error, the supported API versions are:
'2021-04-01,2020-10-01,2020-05-01,2020-02-01,2019-11-01,2018-03-01-beta'

@tombuildsstuff
Copy link
Contributor

hi @Andrei-Predoiu

Thanks for opening this issue.

Digging into this, this appears to be an issue in the upstream API which should be resolved by #14635.

Thanks!

@tombuildsstuff tombuildsstuff added bug service/managed-apps upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR labels Dec 16, 2021
@tombuildsstuff tombuildsstuff modified the milestones: Future, v2.90.0 Dec 16, 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!

@mdepedrof
Copy link

after upgrading to 2.90.0 it no longer crashes but the process of creating ManagementsGroups never ends. I am testing and it takes 22 minutes in "StillCreating" state although in azure it is already created.

image

@mdepedrof
Copy link

@Andrei-Predoiu it working for you?? do you have this behavior?

@BowBart
Copy link

BowBart commented Dec 20, 2021

@crower19 I had the behavior. Did an upgrade of the provider to 2.90.0. It works!

@zahaim
Copy link

zahaim commented Dec 21, 2021

Hello there, I encountered the same problem. After the upgrade to 2.90.0 it no longer crashes but the process of creating ManagementsGroups never ends.


module.management_groups["f92cfe88-1fd0-4353-afc2-21c423f63911"].azurerm_management_group.mg["corp"]: Still creating... [29m30s elapsed]
module.management_groups["f92cfe88-1fd0-4353-afc2-21c423f63911"].azurerm_management_group.mg["corp"]: Still creating... [29m40s elapsed]
module.management_groups["f92cfe88-1fd0-4353-afc2-21c423f63911"].azurerm_management_group.mg["preflight_corp"]: Still creating... [29m40s elapsed]
module.management_groups["f92cfe88-1fd0-4353-afc2-21c423f63911"].azurerm_management_group.mg["preflight_corp"]: Still creating... [29m50s elapsed]
module.management_groups["f92cfe88-1fd0-4353-afc2-21c423f63911"].azurerm_management_group.mg["corp"]: Still creating... [29m50s elapsed]
╷
│ Error: failed when waiting for creation of Management Group "preflight_corp": Future#WaitForCompletion: context has been cancelled: StatusCode=200 -- Original Error: context deadline exceeded
│ 
│   with module.management_groups["f92cfe88-1fd0-4353-afc2-21c423f63911"].azurerm_management_group.mg["preflight_corp"],
│   on modules/management_groups/main.tf line 3, in resource "azurerm_management_group" "mg":
│    3: resource "azurerm_management_group" "mg" {

@BowBart
Copy link

BowBart commented Dec 21, 2021

@zahaim have your tried applying giving it a different management group id? When I changed the id of the management group it ran trough.

@zahaim
Copy link

zahaim commented Dec 21, 2021

@BowBart I use name. Do you suggest using display_name and let Azure generate the id automatically? If possible I would prefer to avoid that, as simple id that equals the name is helpful to apply parent_management_group_id in next steps. But maybe this is an anti-pattern, not sure to be honest.

This is how I create the resource:

resource "azurerm_management_group" "mg" {
    for_each = var.name_subscription
    name               = each.key
    parent_management_group_id = "/providers/Microsoft.Management/managementGroups/${var.parent_management_group_id}"

    subscription_ids = each.value
}

@BowBart
Copy link

BowBart commented Dec 21, 2021

@zahaim I mean the name in this case, which is used as a unique in your tenant I believe. I also first had the long creation time, perhaps because continuous removing and creating. When I changed the group to a different name it worked!

@zahaim
Copy link

zahaim commented Dec 22, 2021

@BowBart ah, ok. Actually, something must have changed on Azure side as today I'm able to create / delete / create the same management groups without problems. I guess it depends on the load on Azure or something. Anyways, thanks for the tip!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, 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 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug service/managed-apps upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants