From bc94b9a47cd87431e81af7568b1fa5122e3198fd Mon Sep 17 00:00:00 2001 From: Yaroslava Serdiuk Date: Tue, 12 Apr 2022 06:08:35 +0000 Subject: [PATCH] Continue CA loop when unregistered nodes were removed --- cluster-autoscaler/core/static_autoscaler.go | 3 +-- cluster-autoscaler/core/static_autoscaler_test.go | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cluster-autoscaler/core/static_autoscaler.go b/cluster-autoscaler/core/static_autoscaler.go index 30f8202c8dfd..b91ec84c9974 100644 --- a/cluster-autoscaler/core/static_autoscaler.go +++ b/cluster-autoscaler/core/static_autoscaler.go @@ -340,8 +340,7 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) errors.AutoscalerError klog.Warningf("Failed to remove unregistered nodes: %v", err) } if removedAny { - klog.V(0).Infof("Some unregistered nodes were removed, skipping iteration") - return nil + klog.V(0).Infof("Some unregistered nodes were removed") } } diff --git a/cluster-autoscaler/core/static_autoscaler_test.go b/cluster-autoscaler/core/static_autoscaler_test.go index e51c433fd5b3..4c1844cd207c 100644 --- a/cluster-autoscaler/core/static_autoscaler_test.go +++ b/cluster-autoscaler/core/static_autoscaler_test.go @@ -291,8 +291,10 @@ func TestStaticAutoscalerRunOnce(t *testing.T) { readyNodeLister.SetNodes([]*apiv1.Node{n1, n2}) allNodeLister.SetNodes([]*apiv1.Node{n1, n2}) scheduledPodMock.On("List").Return([]*apiv1.Pod{p1}, nil).Twice() + unschedulablePodMock.On("List").Return([]*apiv1.Pod{p2}, nil).Once() daemonSetListerMock.On("List", labels.Everything()).Return([]*appsv1.DaemonSet{}, nil).Once() onScaleDownMock.On("ScaleDown", "ng2", "n3").Return(nil).Once() + podDisruptionBudgetListerMock.On("List").Return([]*policyv1.PodDisruptionBudget{}, nil).Once() err = autoscaler.RunOnce(time.Now().Add(5 * time.Hour)) waitForDeleteToFinish(t, autoscaler.scaleDown) @@ -567,8 +569,10 @@ func TestStaticAutoscalerRunOnceWithALongUnregisteredNode(t *testing.T) { readyNodeLister.SetNodes([]*apiv1.Node{n1, n2}) allNodeLister.SetNodes([]*apiv1.Node{n1, n2}) scheduledPodMock.On("List").Return([]*apiv1.Pod{p1}, nil).Twice() + unschedulablePodMock.On("List").Return([]*apiv1.Pod{p2}, nil).Once() onScaleDownMock.On("ScaleDown", "ng1", "broken").Return(nil).Once() daemonSetListerMock.On("List", labels.Everything()).Return([]*appsv1.DaemonSet{}, nil).Once() + podDisruptionBudgetListerMock.On("List").Return([]*policyv1.PodDisruptionBudget{}, nil).Once() err = autoscaler.RunOnce(later.Add(2 * time.Hour)) waitForDeleteToFinish(t, autoscaler.scaleDown)