@@ -2599,28 +2599,35 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
25992599 tests := []struct {
26002600 name string
26012601 testNodes []* apiv1.Node
2602- expectedScaleDownCoolDown bool
2602+ scaleDownInCoolDown bool
26032603 expectedNodesWithSoftTaints []* apiv1.Node
26042604 expectedNodesWithNoSoftTaints []* apiv1.Node
26052605 }{
26062606 {
2607- name : "Soft tainted nodes are cleaned in case of scale down is in cool down " ,
2607+ name : "Soft tainted nodes are cleaned when scale down skipped " ,
26082608 testNodes : nodesToHaveNoTaints ,
2609- expectedScaleDownCoolDown : true ,
2609+ scaleDownInCoolDown : false ,
26102610 expectedNodesWithSoftTaints : []* apiv1.Node {},
26112611 expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
26122612 },
26132613 {
2614- name : "Soft tainted nodes are not cleaned in case of scale down isn't in cool down" ,
2614+ name : "Soft tainted nodes are cleaned when scale down in cooldown" ,
2615+ testNodes : nodesToHaveNoTaints ,
2616+ scaleDownInCoolDown : true ,
2617+ expectedNodesWithSoftTaints : []* apiv1.Node {},
2618+ expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
2619+ },
2620+ {
2621+ name : "Soft tainted nodes are not cleaned when scale down requested" ,
26152622 testNodes : nodesToHaveTaints ,
2616- expectedScaleDownCoolDown : false ,
2623+ scaleDownInCoolDown : false ,
26172624 expectedNodesWithSoftTaints : nodesToHaveTaints ,
26182625 expectedNodesWithNoSoftTaints : []* apiv1.Node {},
26192626 },
26202627 {
2621- name : "Soft tainted nodes are cleaned only from min sized node group in case of scale down isn't in cool down " ,
2628+ name : "Soft tainted nodes are cleaned only from min sized node group when scale down requested " ,
26222629 testNodes : append (nodesToHaveNoTaints , nodesToHaveTaints ... ),
2623- expectedScaleDownCoolDown : false ,
2630+ scaleDownInCoolDown : false ,
26242631 expectedNodesWithSoftTaints : nodesToHaveTaints ,
26252632 expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
26262633 },
@@ -2631,12 +2638,12 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
26312638 fakeClient := buildFakeClient (t , test .testNodes ... )
26322639
26332640 autoscaler := buildStaticAutoscaler (t , provider , test .testNodes , test .testNodes , fakeClient )
2641+ autoscaler .processorCallbacks .disableScaleDownForLoop = test .scaleDownInCoolDown
2642+ assert .Equal (t , autoscaler .isScaleDownInCooldown (time .Now ()), test .scaleDownInCoolDown )
26342643
26352644 err := autoscaler .RunOnce (time .Now ())
26362645
26372646 assert .NoError (t , err )
2638- candidates , _ := autoscaler .processors .ScaleDownNodeProcessor .GetScaleDownCandidates (autoscaler .AutoscalingContext , test .testNodes )
2639- assert .Equal (t , test .expectedScaleDownCoolDown , autoscaler .isScaleDownInCooldown (time .Now (), candidates ))
26402647
26412648 assertNodesSoftTaintsStatus (t , fakeClient , test .expectedNodesWithSoftTaints , true )
26422649 assertNodesSoftTaintsStatus (t , fakeClient , test .expectedNodesWithNoSoftTaints , false )
0 commit comments