Skip to content

Commit

Permalink
Handle cluster cleanup more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciprian Hacman committed Nov 11, 2020
1 parent e72eb08 commit d44e028
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions pkg/resources/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,13 @@ func DeleteVolume(cloud fi.Cloud, r *resources.Resource) error {
}
_, err := c.EC2().DeleteVolume(request)
if err != nil {
if IsDependencyViolation(err) {
return err
}
if awsup.AWSErrorCode(err) == "InvalidVolume.NotFound" {
// Concurrently deleted
klog.V(2).Infof("Got InvalidVolume.NotFound error deleting Volume %q; will treat as already-deleted", id)
return nil
}
if IsDependencyViolation(err) {
return err
}
return fmt.Errorf("error deleting Volume %q: %v", id, err)
}
return nil
Expand Down Expand Up @@ -1731,8 +1731,12 @@ func DeleteElasticIP(cloud fi.Cloud, t *resources.Resource) error {
}
_, err := c.EC2().ReleaseAddress(request)
if err != nil {
if awsup.AWSErrorCode(err) == "AuthFailure" {
klog.V(2).Infof("Got AuthFailure error deleting ElasticIP %q; will treat as already-deleted", id)
return nil
}
if awsup.AWSErrorCode(err) == "InvalidAllocationID.NotFound" {
klog.V(2).Infof("Got InvalidAllocationID.NotFound error describing ElasticIP %q; will treat as already-deleted", id)
klog.V(2).Infof("Got InvalidAllocationID.NotFound error deleting ElasticIP %q; will treat as already-deleted", id)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/aws/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func IsDependencyViolation(err error) bool {
switch code {
case "":
return false
case "DependencyViolation", "VolumeInUse", "InvalidIPAddress.InUse":
case "DependencyViolation", "InvalidIPAddress.InUse", "VolumeInUse", "ResourceInUse":
return true
default:
klog.Infof("unexpected aws error code: %q", code)
Expand Down

0 comments on commit d44e028

Please sign in to comment.