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

resource - fix various tests #27544

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions internal/services/resource/resource_group_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck
"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
Expand Down Expand Up @@ -193,13 +194,16 @@ func resourceResourceGroupDelete(d *pluginsdk.ResourceData, meta interface{}) er
resourceClient := meta.(*clients.Client).Resource.ResourcesClient
// 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(10*time.Minute, func() *pluginsdk.RetryError {
results, err := resourceClient.ListByResourceGroupComplete(ctx, id.ResourceGroup, "", "provisioningState", utils.Int32(500))
results, err := resourceClient.ListByResourceGroup(ctx, id.ResourceGroup, "", "provisioningState", utils.Int32(500))
if err != nil {
if response.WasNotFound(results.Response().Response.Response) {
return nil
}
return pluginsdk.NonRetryableError(fmt.Errorf("listing resources in %s: %v", *id, err))
}
nestedResourceIds := make([]string, 0)
for results.NotDone() {
val := results.Value()
for _, value := range results.Values() {
val := value
if val.ID != nil {
nestedResourceIds = append(nestedResourceIds, *val.ID)
}
Expand All @@ -222,6 +226,9 @@ func resourceResourceGroupDelete(d *pluginsdk.ResourceData, meta interface{}) er

deleteFuture, err := client.Delete(ctx, id.ResourceGroup, "")
if err != nil {
if response.WasNotFound(deleteFuture.Response()) {
return nil
}
return fmt.Errorf("deleting %s: %+v", *id, err)
}

Expand Down
Loading