From ae10191451a2e106e2cf1c0960f9d3573b2f986d Mon Sep 17 00:00:00 2001 From: Dimitri Koshkin Date: Tue, 18 Oct 2022 15:50:30 -0700 Subject: [PATCH 1/2] fix: wrong EKS tag when upgrading older clusters --- pkg/cloud/services/eks/cluster.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/cloud/services/eks/cluster.go b/pkg/cloud/services/eks/cluster.go index d79c11e646..6d3efa98cf 100644 --- a/pkg/cloud/services/eks/cluster.go +++ b/pkg/cloud/services/eks/cluster.go @@ -62,8 +62,14 @@ func (s *Service) reconcileCluster(ctx context.Context) error { } else { tagKey := infrav1.ClusterAWSCloudProviderTagKey(eksClusterName) ownedTag := cluster.Tags[tagKey] - if ownedTag == nil { - return fmt.Errorf("checking owner of %s is %s: %w", s.scope.KubernetesClusterName(), eksClusterName, err) + // Prior to https://github.com/kubernetes-sigs/cluster-api-provider-aws/pull/3573, + // Clusters were tagged using s.scope.Name() + // To support upgrading older clusters, check for both tags + oldTagKey := infrav1.ClusterAWSCloudProviderTagKey(s.scope.Name()) + oldOwnedTag := cluster.Tags[oldTagKey] + + if ownedTag == nil && oldOwnedTag == nil { + return fmt.Errorf("cluster is not tagged with neither %s nor %s", tagKey, oldTagKey) } s.scope.V(2).Info("Found owned EKS cluster in AWS", "cluster", klog.KRef("", eksClusterName)) From c88c19e375dde0fff516eedf5fc84570bc00a680 Mon Sep 17 00:00:00 2001 From: Dimitri Koshkin Date: Tue, 18 Oct 2022 16:28:30 -0700 Subject: [PATCH 2/2] better error message Co-authored-by: Daniel Lipovetsky <3445370+dlipovetsky@users.noreply.github.com> --- pkg/cloud/services/eks/cluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cloud/services/eks/cluster.go b/pkg/cloud/services/eks/cluster.go index 6d3efa98cf..d68a66917f 100644 --- a/pkg/cloud/services/eks/cluster.go +++ b/pkg/cloud/services/eks/cluster.go @@ -69,7 +69,7 @@ func (s *Service) reconcileCluster(ctx context.Context) error { oldOwnedTag := cluster.Tags[oldTagKey] if ownedTag == nil && oldOwnedTag == nil { - return fmt.Errorf("cluster is not tagged with neither %s nor %s", tagKey, oldTagKey) + return fmt.Errorf("EKS cluster resource %q must have a tag with key %q or %q", eksClusterName, oldTagKey, tagKey) } s.scope.V(2).Info("Found owned EKS cluster in AWS", "cluster", klog.KRef("", eksClusterName))