return nil if node is not in an ASG managed by CA

This commit is contained in:
andrewsykim 2016-09-09 11:39:27 -04:00
parent 371f77be88
commit bc6cac07c0
2 changed files with 13 additions and 1 deletions

View File

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

View File

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