Skip to content

Commit

Permalink
aws: Fix infinite loop when failing to untag resources
Browse files Browse the repository at this point in the history
If AWS fails to untag a resource, it ends up going into an
infinite loop of querying tag client for resources and
retrying the untag process.

Trying a solution to retry the untagging of the resource
for a finite time and removing the tag client from the
list if it does not succeed.
  • Loading branch information
rna-afk committed Aug 26, 2022
1 parent 1c8e79b commit 609be18
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/destroy/aws/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi"
Expand Down Expand Up @@ -92,8 +93,14 @@ func (o *ClusterUninstaller) removeSharedTag(ctx context.Context, session *sessi
},
)
if err != nil {
err = errors.Wrap(err, "get tagged resources")
o.Logger.Info(err)
err2 := errors.Wrap(err, "get tagged resources")
o.Logger.Info(err2)
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case resourcegroupstaggingapi.ErrorCodeInvalidParameterException:
continue
}
}
nextTagClients = append(nextTagClients, tagClient)
continue
}
Expand Down

0 comments on commit 609be18

Please sign in to comment.