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

providers/aws: retry destroying internet gateway for some time [GH-447] #448

Merged
merged 2 commits into from
Oct 18, 2014
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ BUG FIXES:
the correct data and don't incorrectly recreate themselves. [GH-425]
* providers/aws: Fix case where ELB would incorrectly plan to modify
listeners (with the same data) in some cases.
* providers/aws: Retry destroying internet gateway for some amount of time
if there is a dependency violation since it is probably just eventual
consistency (public facing resources being destroyed). [GH-447]
* providers/aws: Retry deleting security groups for some amount of time
if there is a dependency violation since it is probably just eventual
consistency. [GH-436]
Expand Down
22 changes: 17 additions & 5 deletions builtin/providers/aws/resource_aws_internet_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,26 @@ func resource_aws_internet_gateway_destroy(
}

log.Printf("[INFO] Deleting Internet Gateway: %s", s.ID)
if _, err := ec2conn.DeleteInternetGateway(s.ID); err != nil {
ec2err, ok := err.(*ec2.Error)
if ok && ec2err.Code == "InvalidInternetGatewayID.NotFound" {
return nil
return resource.Retry(5*time.Minute, func() error {
_, err := ec2conn.DeleteInternetGateway(s.ID)
if err != nil {
ec2err, ok := err.(*ec2.Error)
if !ok {
return err
}

switch ec2err.Code {
case "InvalidInternetGatewayID.NotFound":
return nil
case "DependencyViolation":
return err // retry
default:
return resource.RetryError{err}
}
}

return fmt.Errorf("Error deleting internet gateway: %s", err)
}
})

// Wait for the internet gateway to actually delete
log.Printf("[DEBUG] Waiting for internet gateway (%s) to delete", s.ID)
Expand Down