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

Final retries for redshift resources #9796

Merged
merged 1 commit into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions aws/resource_aws_redshift_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,9 @@ func deleteAwsRedshiftCluster(opts *redshift.DeleteClusterInput, conn *redshift.

return resource.NonRetryableError(err)
})
if isResourceTimeoutError(err) {
_, err = conn.DeleteCluster(opts)
}
if err != nil {
return fmt.Errorf("Error deleting Redshift Cluster (%s): %s", id, err)
}
Expand Down
28 changes: 23 additions & 5 deletions aws/resource_aws_redshift_snapshot_copy_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,21 @@ func findAwsRedshiftSnapshotCopyGrantWithRetry(conn *redshift.Redshift, grantNam

return nil
})

return grant, err
if isResourceTimeoutError(err) {
grant, err = findAwsRedshiftSnapshotCopyGrant(conn, grantName, nil)
}
if err != nil {
return nil, fmt.Errorf("Error finding snapshot copy grant: %s", err)
}
return grant, nil
}

// Used by the tests as well
func waitForAwsRedshiftSnapshotCopyGrantToBeDeleted(conn *redshift.Redshift, grantName string) error {
var grant *redshift.SnapshotCopyGrant
err := resource.Retry(3*time.Minute, func() *resource.RetryError {
grant, err := findAwsRedshiftSnapshotCopyGrant(conn, grantName, nil)
var err error
grant, err = findAwsRedshiftSnapshotCopyGrant(conn, grantName, nil)
if err != nil {
if isAWSErr(err, redshift.ErrCodeSnapshotCopyGrantNotFoundFault, "") {
return nil
Expand All @@ -227,8 +234,16 @@ func waitForAwsRedshiftSnapshotCopyGrantToBeDeleted(conn *redshift.Redshift, gra

return resource.NonRetryableError(err)
})

return err
if isResourceTimeoutError(err) {
grant, err = findAwsRedshiftSnapshotCopyGrant(conn, grantName, nil)
if isAWSErr(err, redshift.ErrCodeSnapshotCopyGrantNotFoundFault, "") {
return nil
}
}
if err != nil {
return fmt.Errorf("Error waiting for snapshot copy grant to be deleted: %s", err)
}
return nil
}

// The DescribeSnapshotCopyGrants API defaults to listing only 100 grants
Expand Down Expand Up @@ -260,6 +275,9 @@ func findAwsRedshiftSnapshotCopyGrant(conn *redshift.Redshift, grantName string,

return nil
})
if isResourceTimeoutError(err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the resource.Retry() above here may be extraneous as it has no return resource.RetryableError() 👍

out, err = conn.DescribeSnapshotCopyGrants(&input)
}
if err != nil {
return nil, err
}
Expand Down