Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1721 from Wattpad/aws-ca-bug-instance-not-in-know…
Browse files Browse the repository at this point in the history
…n-group

AWS Cluster Autoscaler: NodeGroupForNode should return nil if instance is not in any known ASG
  • Loading branch information
mwielgus authored Sep 12, 2016
2 parents 186beff + fa8d4cd commit 4e617b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions cluster-autoscaler/cloudprovider/aws/aws_cloud_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ func TestNodeGroupForNode(t *testing.T) {
assert.Equal(t, group.Id(), "test-asg")
assert.Equal(t, group.MinSize(), 1)
assert.Equal(t, group.MaxSize(), 5)

// test node in cluster that is not in a group managed by cluster autoscaler
nodeNotInGroup := &kube_api.Node{
Spec: kube_api.NodeSpec{
ProviderID: "aws:///us-east-1a/test-instance-id-not-in-group",
},
}

group, err = provider.NodeGroupForNode(nodeNotInGroup)
assert.NoError(t, err)
assert.Nil(t, group)
}

func TestAwsRefFromProviderId(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion cluster-autoscaler/cloudprovider/aws/aws_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ func (m *AwsManager) GetAsgForInstance(instance *AwsRef) (*Asg, error) {
if config, found := m.asgCache[*instance]; found {
return config, nil
}
return nil, fmt.Errorf("Instance %+v does not belong to any known ASG", *instance)
// instance does not belong to any configured ASG
return nil, nil
}

func (m *AwsManager) regenerateCache() error {
Expand Down

0 comments on commit 4e617b9

Please sign in to comment.