Skip to content

Commit

Permalink
Add retry of destroy CNames
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Mar 7, 2022
1 parent 06c8f38 commit 5b647ad
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion internal/provider/resource_tsuru_app_cname.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,21 @@ func resourceTsuruApplicationCNameDelete(ctx context.Context, d *schema.Resource
Cname: []string{hostname},
}

_, err := provider.TsuruClient.AppApi.AppCnameDelete(ctx, app, cname)
err := resource.RetryContext(ctx, d.Timeout(schema.TimeoutDelete), func() *resource.RetryError {
_, err := provider.TsuruClient.AppApi.AppCnameDelete(ctx, app, cname)
if err != nil {
var apiError tsuru_client.GenericOpenAPIError
if errors.As(err, &apiError) {
if isRetryableError(apiError.Body()) {
return resource.RetryableError(err)
}
return resource.NonRetryableError(err)
}
}

return nil
})

if err != nil {
return diag.Errorf("unable to delete cname: %v", err)
}
Expand Down

0 comments on commit 5b647ad

Please sign in to comment.