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

AWS Cluster Autoscaler: NodeGroupForNode should return nil if instance is not in any known ASG #1721

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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