diff --git a/pkg/cloudprovider/providers/aws/aws_test.go b/pkg/cloudprovider/providers/aws/aws_test.go index 8ea62cae386..1d307c6169b 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"), } 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