Merge pull request #60125 from vainu-arto/aws-missing-tags-error

Automatic merge from submit-queue (batch tested with PRs 60435, 60334, 60458, 59301, 60125). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Return missing ClusterID error instead of ignoring it

This fixes issue #57382. In the cases I'm aware of kubelet cannot function if it can't detect the cluster it is running in, so the error should be passed up to the caller preventing initialization when kubelet would fail. This way the error can be detected and kubelet startup attempted again later (giving AWS time to apply the tags).

```release-note
On AWS kubelet returns an error when started under conditions that do not allow it to work (AWS has not yet tagged the instance).
```
pull/6/head
Kubernetes Submit Queue 2018-02-26 17:48:54 -08:00 committed by GitHub
commit 3ca89a3469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -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"),
}

View File

@ -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