Skip to content

Commit

Permalink
retry on update and poll
Browse files Browse the repository at this point in the history
  • Loading branch information
lonegunmanb committed Jun 1, 2022
1 parent 571daa0 commit 3ecf745
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions internal/services/network/private_endpoint_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,22 @@ func resourcePrivateEndpointCreate(d *pluginsdk.ResourceData, meta interface{})
//goland:noinspection GoDeferInLoop
defer locks.UnlockByName(cosmosDbResId, "azurerm_private_endpoint")
}

future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, parameters)
if err != nil {
if strings.EqualFold(err.Error(), "is missing required parameter 'group Id'") {
return fmt.Errorf("creating Private Endpoint %q (Resource Group %q) due to missing 'group Id', ensure that the 'subresource_names' type is populated: %+v", id.Name, id.ResourceGroup, err)
} else {
return fmt.Errorf("creating Private Endpoint %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err)
}
}
err = pluginsdk.Retry(d.Timeout(pluginsdk.TimeoutCreate), func() *resource.RetryError {
future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, parameters)
if err != nil {
if strings.EqualFold(err.Error(), "is missing required parameter 'group Id'") {
return &resource.RetryError{
Err: fmt.Errorf("creating Private Endpoint %q (Resource Group %q) due to missing 'group Id', ensure that the 'subresource_names' type is populated: %+v", id.Name, id.ResourceGroup, err),
Retryable: false,
}
} else {
return &resource.RetryError{
Err: fmt.Errorf("creating Private Endpoint %q (Resource Group %q): %+v", id.Name, id.ResourceGroup, err),
Retryable: false,
}
}
}

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),
Expand Down

0 comments on commit 3ecf745

Please sign in to comment.