Skip to content

Commit

Permalink
Merge pull request #4660 from giantswarm/no-error-missing-asg-instanc…
Browse files Browse the repository at this point in the history
…e-refresh

🐛 Don't error if ASG is missing when deciding to refresh instances
  • Loading branch information
k8s-ci-robot authored Nov 28, 2023
2 parents 2562a8b + ccf78b4 commit 25f8108
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/cloud/services/autoscaling/autoscalinggroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ func (s *Service) CanStartASGInstanceRefresh(scope *scope.MachinePoolScope) (boo
describeInput := &autoscaling.DescribeInstanceRefreshesInput{AutoScalingGroupName: aws.String(scope.Name())}
refreshes, err := s.ASGClient.DescribeInstanceRefreshesWithContext(context.TODO(), describeInput)
if err != nil {
if awserrors.IsNotFound(err) {
return false, nil
}
return false, err
}
hasUnfinishedRefresh := false
Expand Down
11 changes: 11 additions & 0 deletions pkg/cloud/services/autoscaling/autoscalinggroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,17 @@ func TestServiceCanStartASGInstanceRefresh(t *testing.T) {
name: "should return error if describe instance refresh failed",
wantErr: true,
canStart: false,
expect: func(m *mock_autoscalingiface.MockAutoScalingAPIMockRecorder) {
m.DescribeInstanceRefreshesWithContext(context.TODO(), gomock.Eq(&autoscaling.DescribeInstanceRefreshesInput{
AutoScalingGroupName: aws.String("machinePoolName"),
})).
Return(nil, awserrors.NewConflict("some error"))
},
},
{
name: "should NOT return error if describe instance failed due to 'not found'",
wantErr: false,
canStart: false,
expect: func(m *mock_autoscalingiface.MockAutoScalingAPIMockRecorder) {
m.DescribeInstanceRefreshesWithContext(context.TODO(), gomock.Eq(&autoscaling.DescribeInstanceRefreshesInput{
AutoScalingGroupName: aws.String("machinePoolName"),
Expand Down

0 comments on commit 25f8108

Please sign in to comment.