Skip to content

Commit

Permalink
Merge pull request #2373 from losipiuk/lo/cherry-pick-2357-1-16
Browse files Browse the repository at this point in the history
Don't treat lack of queried node in cache as error (cherry-pick to 1.16)
  • Loading branch information
k8s-ci-robot authored Sep 23, 2019
2 parents d787bf9 + 0edbc5d commit f44388a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (aws *awsCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N
asg := aws.awsManager.GetAsgForInstance(*ref)

if asg == nil {
return nil, fmt.Errorf("cannot find ASG for node %v", ref.Name)
return nil, nil
}

return &AwsNodeGroup{
Expand Down
23 changes: 10 additions & 13 deletions cluster-autoscaler/cloudprovider/aws/aws_cloud_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,36 +241,33 @@ func TestNodeGroupForNode(t *testing.T) {

assert.Equal(t, []cloudprovider.Instance{{Id: "aws:///us-east-1a/test-instance-id"}}, nodes)
service.AssertNumberOfCalls(t, "DescribeAutoScalingGroupsPages", 1)
}

func TestNodeGroupForNodeWithNoProviderId(t *testing.T) {
node := &apiv1.Node{
// test node in cluster that is not in a group managed by cluster autoscaler
nodeNotInGroup := &apiv1.Node{
Spec: apiv1.NodeSpec{
ProviderID: "",
ProviderID: "aws:///us-east-1a/test-instance-id-not-in-group",
},
}
service := &AutoScalingMock{}
provider := testProvider(t, newTestAwsManagerWithAsgs(t, service, []string{"1:5:test-asg"}))
group, err := provider.NodeGroupForNode(node)

group, err = provider.NodeGroupForNode(nodeNotInGroup)

assert.NoError(t, err)
assert.Equal(t, group, nil)
assert.Nil(t, group)
service.AssertNumberOfCalls(t, "DescribeAutoScalingGroupsPages", 1)
}

func TestNodeGroupForNodeWithOutNodeGroup(t *testing.T) {
// test node in cluster that is not in a group managed by cluster autoscaler
func TestNodeGroupForNodeWithNoProviderId(t *testing.T) {
node := &apiv1.Node{
Spec: apiv1.NodeSpec{
ProviderID: "aws:///us-east-1a/test-instance-id",
ProviderID: "",
},
}
service := &AutoScalingMock{}
provider := testProvider(t, newTestAwsManagerWithAsgs(t, service, []string{"1:5:test-asg"}))
group, err := provider.NodeGroupForNode(node)

assert.Error(t, err)
assert.NoError(t, err)
assert.Equal(t, group, nil)
service.AssertNotCalled(t, "DescribeAutoScalingGroupsPages")
}

func TestAwsRefFromProviderId(t *testing.T) {
Expand Down

0 comments on commit f44388a

Please sign in to comment.