From d44e028ed20419fc29bc7e10271ad8b580ffc62f Mon Sep 17 00:00:00 2001 From: Ciprian Hacman Date: Wed, 11 Nov 2020 11:19:13 +0200 Subject: [PATCH] Handle cluster cleanup more gracefully --- pkg/resources/aws/aws.go | 14 +++++++++----- pkg/resources/aws/errors.go | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/resources/aws/aws.go b/pkg/resources/aws/aws.go index ce5f12ea75a52..ee1095cfcc299 100644 --- a/pkg/resources/aws/aws.go +++ b/pkg/resources/aws/aws.go @@ -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 @@ -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 } diff --git a/pkg/resources/aws/errors.go b/pkg/resources/aws/errors.go index bb7cf6ed9d9b7..706e72a2ef84c 100644 --- a/pkg/resources/aws/errors.go +++ b/pkg/resources/aws/errors.go @@ -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)