From ccf78b4c721c3d075a42c9eb02738ccb1e8ee295 Mon Sep 17 00:00:00 2001 From: Jose Armesto Date: Mon, 27 Nov 2023 12:58:26 +0100 Subject: [PATCH] Don't error if ASG is missing when deciding to refresh instances --- pkg/cloud/services/autoscaling/autoscalinggroup.go | 3 +++ .../services/autoscaling/autoscalinggroup_test.go | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/pkg/cloud/services/autoscaling/autoscalinggroup.go b/pkg/cloud/services/autoscaling/autoscalinggroup.go index fb471c7d0f..cea424063f 100644 --- a/pkg/cloud/services/autoscaling/autoscalinggroup.go +++ b/pkg/cloud/services/autoscaling/autoscalinggroup.go @@ -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 diff --git a/pkg/cloud/services/autoscaling/autoscalinggroup_test.go b/pkg/cloud/services/autoscaling/autoscalinggroup_test.go index 452fe6f777..ed8b9f4ec6 100644 --- a/pkg/cloud/services/autoscaling/autoscalinggroup_test.go +++ b/pkg/cloud/services/autoscaling/autoscalinggroup_test.go @@ -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"),