From a58f16bdfa3455fc5e63c0f10f96132c113d3cb0 Mon Sep 17 00:00:00 2001 From: Arto Jantunen Date: Mon, 26 Feb 2018 14:36:35 +0200 Subject: [PATCH 1/2] Add clusterid tags to the instances in AWS tests In practice these were in most cases required to exist, but kubelet did not previously enforce this. It now does, so these tests need to change a bit. --- pkg/cloudprovider/providers/aws/aws_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/cloudprovider/providers/aws/aws_test.go b/pkg/cloudprovider/providers/aws/aws_test.go index 5e9601730b7..97f8df62a92 100644 --- a/pkg/cloudprovider/providers/aws/aws_test.go +++ b/pkg/cloudprovider/providers/aws/aws_test.go @@ -272,6 +272,12 @@ func TestNodeAddresses(t *testing.T) { var instance1 ec2.Instance var instance2 ec2.Instance + // ClusterID needs to be set + var tag ec2.Tag + tag.Key = aws.String(TagNameKubernetesClusterLegacy) + tag.Value = aws.String(TestClusterId) + tags := []*ec2.Tag{&tag} + //0 instance0.InstanceId = aws.String("i-0") instance0.PrivateDnsName = aws.String("instance-same.ec2.internal") @@ -290,6 +296,7 @@ func TestNodeAddresses(t *testing.T) { } instance0.InstanceType = aws.String("c3.large") instance0.Placement = &ec2.Placement{AvailabilityZone: aws.String("us-east-1a")} + instance0.Tags = tags state0 := ec2.InstanceState{ Name: aws.String("running"), } @@ -301,6 +308,7 @@ func TestNodeAddresses(t *testing.T) { instance1.PrivateIpAddress = aws.String("192.168.0.2") instance1.InstanceType = aws.String("c3.large") instance1.Placement = &ec2.Placement{AvailabilityZone: aws.String("us-east-1a")} + instance1.Tags = tags state1 := ec2.InstanceState{ Name: aws.String("running"), } @@ -313,6 +321,7 @@ func TestNodeAddresses(t *testing.T) { instance2.PublicIpAddress = aws.String("1.2.3.4") instance2.InstanceType = aws.String("c3.large") instance2.Placement = &ec2.Placement{AvailabilityZone: aws.String("us-east-1a")} + instance2.Tags = tags state2 := ec2.InstanceState{ Name: aws.String("running"), } @@ -351,12 +360,19 @@ func TestNodeAddresses(t *testing.T) { func TestNodeAddressesWithMetadata(t *testing.T) { var instance ec2.Instance + // ClusterID needs to be set + var tag ec2.Tag + tag.Key = aws.String(TagNameKubernetesClusterLegacy) + tag.Value = aws.String(TestClusterId) + tags := []*ec2.Tag{&tag} + instanceName := "instance.ec2.internal" instance.InstanceId = aws.String("i-0") instance.PrivateDnsName = &instanceName instance.PublicIpAddress = aws.String("2.3.4.5") instance.InstanceType = aws.String("c3.large") instance.Placement = &ec2.Placement{AvailabilityZone: aws.String("us-east-1a")} + instance.Tags = tags state := ec2.InstanceState{ Name: aws.String("running"), } From cba110aa3daf1f094a4e7651e2af007a4bb47014 Mon Sep 17 00:00:00 2001 From: Arto Jantunen Date: Wed, 21 Feb 2018 08:40:59 +0200 Subject: [PATCH 2/2] Return missing ClusterID error instead of ignoring it This fixes issue #57382. --- 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 bb63fce2bfd..40947cb379f 100644 --- a/pkg/cloudprovider/providers/aws/tags.go +++ b/pkg/cloudprovider/providers/aws/tags.go @@ -75,7 +75,7 @@ func (t *awsTagging) init(legacyClusterID string, clusterID string) error { if clusterID != "" { glog.Infof("AWS cloud filtering on ClusterID: %v", clusterID) } else { - glog.Warning("AWS cloud - no clusterID filtering applied for shared resources; do not run multiple clusters in this AZ.") + return fmt.Errorf("AWS cloud failed to find ClusterID") } return nil