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

cdn: Add test sweeper and retry with backoff. #947

Merged
merged 5 commits into from
Feb 14, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cdn: Add retry on delete.
  • Loading branch information
andrewsomething committed Feb 13, 2023
commit b258f73cfa8ea3f480377fdbad86e1f8cd1af045
16 changes: 15 additions & 1 deletion digitalocean/cdn/resource_cdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,21 @@ func resourceDigitalOceanCDNDelete(ctx context.Context, d *schema.ResourceData,
client := meta.(*config.CombinedConfig).GodoClient()
resourceID := d.Id()

_, err := client.CDNs.Delete(context.Background(), resourceID)
timeout := 30 * time.Second
err := resource.RetryContext(ctx, timeout, func() *resource.RetryError {
_, err := client.CDNs.Delete(context.Background(), resourceID)
if err != nil {
if util.IsDigitalOceanError(err, http.StatusTooManyRequests, "") {
log.Printf("[DEBUG] Received %s, backing off", err.Error())
time.Sleep(10 * time.Second)
return resource.RetryableError(err)
}

return resource.NonRetryableError(err)
}

return nil
})
if err != nil {
return diag.Errorf("Error deleting CDN: %s", err)
}
Expand Down