Skip to content

Commit 202c28e

Browse files
authored
Retry database delete if response is 409 (#328)
Fixes #327
1 parent 4d0d598 commit 202c28e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/provider/resource_database.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var availableDbTypes = []string{
2828

2929
var databaseCreateTimeout = time.Minute * 40
3030
var databaseReadTimeout = time.Minute * 5
31-
var databaseDeleteTimeout = time.Minute * 20
31+
var databaseDeleteTimeout = time.Minute * 40
3232
var databaseUpdateTimeout = time.Minute * 40
3333

3434
func resourceDatabase() *schema.Resource {
@@ -323,6 +323,11 @@ func resourceDatabaseDelete(ctx context.Context, resourceData *schema.ResourceDa
323323
return nil
324324
}
325325

326+
// If the database is in Maintenance state, it will return a 409. We can retry this
327+
if resp.StatusCode() == http.StatusConflict {
328+
return retry.RetryableError(fmt.Errorf("Unable to terminate database %s. %s", databaseID, string(resp.Body)))
329+
}
330+
326331
// All other 4XX status codes are NOT retried
327332
if resp.StatusCode() >= http.StatusBadRequest {
328333
return retry.NonRetryableError(fmt.Errorf("unexpected response attempting to terminate database. Status code: %d, message = %s", resp.StatusCode(), string(resp.Body)))

0 commit comments

Comments
 (0)