Skip to content

Commit ae10191

Browse files
committed
fix: wrong EKS tag when upgrading older clusters
1 parent b58d614 commit ae10191

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/cloud/services/eks/cluster.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,14 @@ func (s *Service) reconcileCluster(ctx context.Context) error {
6262
} else {
6363
tagKey := infrav1.ClusterAWSCloudProviderTagKey(eksClusterName)
6464
ownedTag := cluster.Tags[tagKey]
65-
if ownedTag == nil {
66-
return fmt.Errorf("checking owner of %s is %s: %w", s.scope.KubernetesClusterName(), eksClusterName, err)
65+
// Prior to https://github.com/kubernetes-sigs/cluster-api-provider-aws/pull/3573,
66+
// Clusters were tagged using s.scope.Name()
67+
// To support upgrading older clusters, check for both tags
68+
oldTagKey := infrav1.ClusterAWSCloudProviderTagKey(s.scope.Name())
69+
oldOwnedTag := cluster.Tags[oldTagKey]
70+
71+
if ownedTag == nil && oldOwnedTag == nil {
72+
return fmt.Errorf("cluster is not tagged with neither %s nor %s", tagKey, oldTagKey)
6773
}
6874

6975
s.scope.V(2).Info("Found owned EKS cluster in AWS", "cluster", klog.KRef("", eksClusterName))

0 commit comments

Comments
 (0)