Merge pull request #449 from pmoust/subnet-destroy-retry
providers/aws: retry destroying subnet for some time [GH-449]
This commit is contained in:
commit
6eb409c00e
|
@ -20,6 +20,9 @@ BUG FIXES:
|
||||||
* providers/aws: Retry deleting security groups for some amount of time
|
* providers/aws: Retry deleting security groups for some amount of time
|
||||||
if there is a dependency violation since it is probably just eventual
|
if there is a dependency violation since it is probably just eventual
|
||||||
consistency. [GH-436]
|
consistency. [GH-436]
|
||||||
|
* providers/aws: Retry deleting subnet for some amount of time if there is a
|
||||||
|
dependency violation since probably asynchronous destroy events take
|
||||||
|
place still. [GH-449]
|
||||||
* providers/aws: Drain autoscale groups before deleting. [GH-435]
|
* providers/aws: Drain autoscale groups before deleting. [GH-435]
|
||||||
* providers/aws: Fix crash case if launch config is manually deleted. [GH-421]
|
* providers/aws: Fix crash case if launch config is manually deleted. [GH-421]
|
||||||
|
|
||||||
|
|
|
@ -88,18 +88,26 @@ func resource_aws_subnet_destroy(
|
||||||
ec2conn := p.ec2conn
|
ec2conn := p.ec2conn
|
||||||
|
|
||||||
log.Printf("[INFO] Deleting Subnet: %s", s.ID)
|
log.Printf("[INFO] Deleting Subnet: %s", s.ID)
|
||||||
f := func() error {
|
return resource.Retry(5*time.Minute, func() error {
|
||||||
_, err := ec2conn.DeleteSubnet(s.ID)
|
_, err := ec2conn.DeleteSubnet(s.ID)
|
||||||
|
if err != nil {
|
||||||
|
ec2err, ok := err.(*ec2.Error)
|
||||||
|
if !ok {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := resource.Retry(10*time.Second, f); err != nil {
|
|
||||||
ec2err, ok := err.(*ec2.Error)
|
switch ec2err.Code {
|
||||||
if ok && ec2err.Code == "InvalidSubnetID.NotFound" {
|
case "InvalidSubnetID.NotFound":
|
||||||
return nil
|
return nil
|
||||||
|
case "DependencyViolation":
|
||||||
|
return err // retry
|
||||||
|
default:
|
||||||
|
return resource.RetryError{err}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("Error deleting subnet: %s", err)
|
return fmt.Errorf("Error deleting subnet: %s", err)
|
||||||
}
|
})
|
||||||
|
|
||||||
// Wait for the Subnet to actually delete
|
// Wait for the Subnet to actually delete
|
||||||
log.Printf("[DEBUG] Waiting for subnet (%s) to delete", s.ID)
|
log.Printf("[DEBUG] Waiting for subnet (%s) to delete", s.ID)
|
||||||
|
|
Loading…
Reference in New Issue