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

azurerm_resource_group - Wait for eventual consistency when deleting #16073

Merged
merged 4 commits into from
Mar 25, 2022

Conversation

mbfrahry
Copy link
Member

A new feature was added in 3.0 that checks to see if there are any resources being managed by a resource group before deleting that resource group. Unfortunately, it seems there is a bit of eventual consistency that causes the resource group to think those resources are still around when they have been deleted.

To fix that, we'll do that check a few times before we actually error out because the resources are still around.

Fixes #16069

@mbfrahry mbfrahry changed the title azurerm_resource_group Account for eventual consistency when deleting azurerm_resource_group - Wait for eventual consistency when deleting Mar 25, 2022
@mbfrahry mbfrahry requested a review from a team March 25, 2022 18:31
Copy link
Member

@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.

LGTM! 🎩

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.

Aside from a slight change to the sleep and timeout this LGTM 🌻

return resourceGroupContainsItemsError(id.ResourceGroup, nestedResourceIds)
}
if len(nestedResourceIds) > 0 {
time.Sleep(15 * time.Second)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
time.Sleep(15 * time.Second)
time.Sleep(30 * time.Second)

if val.ID != nil {
nestedResourceIds = append(nestedResourceIds, *val.ID)
// Resource groups sometimes hold on to resource information after the resources have been deleted. We'll retry this check to account for that eventual consistency.
err = pluginsdk.Retry(time.Minute*5, func() *pluginsdk.RetryError {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
err = pluginsdk.Retry(time.Minute*5, func() *pluginsdk.RetryError {
err = pluginsdk.Retry(time.Minute*2, func() *pluginsdk.RetryError {

@mbfrahry mbfrahry merged commit e34d759 into main Mar 25, 2022
@mbfrahry mbfrahry deleted the threeoh-resouregroup-wait branch March 25, 2022 20:36
@mbfrahry mbfrahry added this to the v3.0.2 milestone Mar 25, 2022
mbfrahry added a commit that referenced this pull request Mar 25, 2022
@github-actions
Copy link

This functionality has been released in v3.0.2 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 Apr 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v3.0.1: Cannot destroy eventhub namespace due to the error "The Resource Group still contains Resources"
3 participants