Skip to content

Commit 25f8108

Browse files
authored
Merge pull request #4660 from giantswarm/no-error-missing-asg-instance-refresh
🐛 Don't error if ASG is missing when deciding to refresh instances
2 parents 2562a8b + ccf78b4 commit 25f8108

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/cloud/services/autoscaling/autoscalinggroup.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ func (s *Service) CanStartASGInstanceRefresh(scope *scope.MachinePoolScope) (boo
323323
describeInput := &autoscaling.DescribeInstanceRefreshesInput{AutoScalingGroupName: aws.String(scope.Name())}
324324
refreshes, err := s.ASGClient.DescribeInstanceRefreshesWithContext(context.TODO(), describeInput)
325325
if err != nil {
326+
if awserrors.IsNotFound(err) {
327+
return false, nil
328+
}
326329
return false, err
327330
}
328331
hasUnfinishedRefresh := false

pkg/cloud/services/autoscaling/autoscalinggroup_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,17 @@ func TestServiceCanStartASGInstanceRefresh(t *testing.T) {
10871087
name: "should return error if describe instance refresh failed",
10881088
wantErr: true,
10891089
canStart: false,
1090+
expect: func(m *mock_autoscalingiface.MockAutoScalingAPIMockRecorder) {
1091+
m.DescribeInstanceRefreshesWithContext(context.TODO(), gomock.Eq(&autoscaling.DescribeInstanceRefreshesInput{
1092+
AutoScalingGroupName: aws.String("machinePoolName"),
1093+
})).
1094+
Return(nil, awserrors.NewConflict("some error"))
1095+
},
1096+
},
1097+
{
1098+
name: "should NOT return error if describe instance failed due to 'not found'",
1099+
wantErr: false,
1100+
canStart: false,
10901101
expect: func(m *mock_autoscalingiface.MockAutoScalingAPIMockRecorder) {
10911102
m.DescribeInstanceRefreshesWithContext(context.TODO(), gomock.Eq(&autoscaling.DescribeInstanceRefreshesInput{
10921103
AutoScalingGroupName: aws.String("machinePoolName"),

0 commit comments

Comments
 (0)