Skip to content

Commit

Permalink
try to add retry on creation
Browse files Browse the repository at this point in the history
  • Loading branch information
lonegunmanb committed May 31, 2022
1 parent 1774626 commit 571daa0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions internal/services/network/private_endpoint_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-08-01/network"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -299,8 +300,17 @@ func resourcePrivateEndpointCreate(d *pluginsdk.ResourceData, meta interface{})
return fmt.Errorf("creating Private Endpoint %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
}
}
if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {
return fmt.Errorf("waiting for creation of Private Endpoint %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
err = pluginsdk.Retry(d.Timeout(pluginsdk.TimeoutCreate), func() *resource.RetryError {
if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {
return &resource.RetryError{
Err: fmt.Errorf("waiting for creation of Private Endpoint %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err),
Retryable: strings.Contains(strings.ToLower(err.Error()), "retryable"),
}
}
return nil
})
if err != nil {
return err
}

d.SetId(id.ID())
Expand Down

0 comments on commit 571daa0

Please sign in to comment.