From 0a95581de08a9d83d803fbf760a2912272c71d46 Mon Sep 17 00:00:00 2001 From: Tim Wilfong Date: Wed, 23 May 2018 13:54:20 -0700 Subject: [PATCH 1/3] Update function hasClusterTag to fix issue #64230 Fixes issue #64230, by changing function hasClusterTag, in aws/tags.go, to ensure that a list of tags containing a tag with a key which matches clusterTagKey will return true even if a TagNameKubernetesClusterLegacy tag also exists in the list with a value other than the ClusterID. /sig aws --- pkg/cloudprovider/providers/aws/tags.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cloudprovider/providers/aws/tags.go b/pkg/cloudprovider/providers/aws/tags.go index 40947cb379f..2a293e7271f 100644 --- a/pkg/cloudprovider/providers/aws/tags.go +++ b/pkg/cloudprovider/providers/aws/tags.go @@ -137,14 +137,14 @@ func (t *awsTagging) hasClusterTag(tags []*ec2.Tag) bool { clusterTagKey := t.clusterTagKey() for _, tag := range tags { tagKey := aws.StringValue(tag.Key) + // Check if this is a newer-style cluster tag before checking if legacy tag value matches ClusterID + if tagKey == clusterTagKey { + return true + } // For 1.6, we continue to recognize the legacy tags, for the 1.5 -> 1.6 upgrade if tagKey == TagNameKubernetesClusterLegacy { return aws.StringValue(tag.Value) == t.ClusterID } - - if tagKey == clusterTagKey { - return true - } } return false } From d8d2a4e84c892ab476d3f5fc4d0b5a10487237b7 Mon Sep 17 00:00:00 2001 From: Tim Wilfong Date: Thu, 24 May 2018 16:21:01 -0700 Subject: [PATCH 2/3] fix space-vs-tab indent on comment line --- pkg/cloudprovider/providers/aws/tags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cloudprovider/providers/aws/tags.go b/pkg/cloudprovider/providers/aws/tags.go index 2a293e7271f..2daff4d4e4c 100644 --- a/pkg/cloudprovider/providers/aws/tags.go +++ b/pkg/cloudprovider/providers/aws/tags.go @@ -137,7 +137,7 @@ func (t *awsTagging) hasClusterTag(tags []*ec2.Tag) bool { clusterTagKey := t.clusterTagKey() for _, tag := range tags { tagKey := aws.StringValue(tag.Key) - // Check if this is a newer-style cluster tag before checking if legacy tag value matches ClusterID + // Check if this is a newer-style cluster tag before checking if legacy tag value matches ClusterID if tagKey == clusterTagKey { return true } From fc1d9dbd181043003172adebcd23ea12e01f4b65 Mon Sep 17 00:00:00 2001 From: Tim Wilfong Date: Thu, 24 May 2018 19:23:12 -0700 Subject: [PATCH 3/3] Fix hasClusterTag to actually get behavior we want --- pkg/cloudprovider/providers/aws/tags.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/cloudprovider/providers/aws/tags.go b/pkg/cloudprovider/providers/aws/tags.go index 2daff4d4e4c..43130c3601f 100644 --- a/pkg/cloudprovider/providers/aws/tags.go +++ b/pkg/cloudprovider/providers/aws/tags.go @@ -137,13 +137,13 @@ func (t *awsTagging) hasClusterTag(tags []*ec2.Tag) bool { clusterTagKey := t.clusterTagKey() for _, tag := range tags { tagKey := aws.StringValue(tag.Key) - // Check if this is a newer-style cluster tag before checking if legacy tag value matches ClusterID - if tagKey == clusterTagKey { + // For 1.6, we continue to recognize the legacy tags, for the 1.5 -> 1.6 upgrade + // Note that we want to continue traversing tag list if we see a legacy tag with value != ClusterID + if (tagKey == TagNameKubernetesClusterLegacy) && (aws.StringValue(tag.Value) == t.ClusterID) { return true } - // For 1.6, we continue to recognize the legacy tags, for the 1.5 -> 1.6 upgrade - if tagKey == TagNameKubernetesClusterLegacy { - return aws.StringValue(tag.Value) == t.ClusterID + if tagKey == clusterTagKey { + return true } } return false