From f240c27e16cdf64913a2725055af4f43cc18609e Mon Sep 17 00:00:00 2001 From: Panagiotis Moustafellos Date: Sat, 18 Oct 2014 11:47:33 +0300 Subject: [PATCH 1/2] providers/aws: retry destroying internet gateway for some time [GH-447] --- .../aws/resource_aws_internet_gateway.go | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/builtin/providers/aws/resource_aws_internet_gateway.go b/builtin/providers/aws/resource_aws_internet_gateway.go index a13892c60..fc23ebb06 100644 --- a/builtin/providers/aws/resource_aws_internet_gateway.go +++ b/builtin/providers/aws/resource_aws_internet_gateway.go @@ -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) From 3cea56b4a29894c7b20078a97560c1fedc8ae862 Mon Sep 17 00:00:00 2001 From: Panagiotis Moustafellos Date: Sat, 18 Oct 2014 11:52:08 +0300 Subject: [PATCH 2/2] Updated changelog for [GH-447] --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24402be8a..79f41b26c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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]