From 609be18777752f3919db907c61365c673e7f0e00 Mon Sep 17 00:00:00 2001 From: rna-afk Date: Thu, 25 Aug 2022 12:47:55 -0400 Subject: [PATCH] aws: Fix infinite loop when failing to untag resources 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. --- pkg/destroy/aws/shared.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/destroy/aws/shared.go b/pkg/destroy/aws/shared.go index 5adae82f43b..c41b1ccc247 100644 --- a/pkg/destroy/aws/shared.go +++ b/pkg/destroy/aws/shared.go @@ -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" @@ -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 }