@@ -2651,28 +2651,35 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
2651
2651
tests := []struct {
2652
2652
name string
2653
2653
testNodes []* apiv1.Node
2654
- expectedScaleDownCoolDown bool
2654
+ scaleDownInCoolDown bool
2655
2655
expectedNodesWithSoftTaints []* apiv1.Node
2656
2656
expectedNodesWithNoSoftTaints []* apiv1.Node
2657
2657
}{
2658
2658
{
2659
- name : "Soft tainted nodes are cleaned in case of scale down is in cool down " ,
2659
+ name : "Soft tainted nodes are cleaned when scale down skipped " ,
2660
2660
testNodes : nodesToHaveNoTaints ,
2661
- expectedScaleDownCoolDown : true ,
2661
+ expectedScaleDownCoolDown : false ,
2662
+ expectedNodesWithSoftTaints : []* apiv1.Node {},
2663
+ expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
2664
+ },
2665
+ {
2666
+ name : "Soft tainted nodes are cleaned when scale down in cooldown" ,
2667
+ testNodes : nodesToHaveNoTaints ,
2668
+ scaleDownInCoolDown : true ,
2662
2669
expectedNodesWithSoftTaints : []* apiv1.Node {},
2663
2670
expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
2664
2671
},
2665
2672
{
2666
2673
name : "Soft tainted nodes are not cleaned in case of scale down isn't in cool down" ,
2667
2674
testNodes : nodesToHaveTaints ,
2668
- expectedScaleDownCoolDown : false ,
2675
+ scaleDownInCoolDown : false ,
2669
2676
expectedNodesWithSoftTaints : nodesToHaveTaints ,
2670
2677
expectedNodesWithNoSoftTaints : []* apiv1.Node {},
2671
2678
},
2672
2679
{
2673
2680
name : "Soft tainted nodes are cleaned only from min sized node group in case of scale down isn't in cool down" ,
2674
2681
testNodes : append (nodesToHaveNoTaints , nodesToHaveTaints ... ),
2675
- expectedScaleDownCoolDown : false ,
2682
+ scaleDownInCoolDown : false ,
2676
2683
expectedNodesWithSoftTaints : nodesToHaveTaints ,
2677
2684
expectedNodesWithNoSoftTaints : nodesToHaveNoTaints ,
2678
2685
},
@@ -2683,12 +2690,12 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
2683
2690
fakeClient := buildFakeClient (t , test .testNodes ... )
2684
2691
2685
2692
autoscaler := buildStaticAutoscaler (t , provider , test .testNodes , test .testNodes , fakeClient )
2693
+ autoscaler .processorCallbacks .disableScaleDownForLoop = test .scaleDownInCoolDown
2694
+ assert .Equal (t , autoscaler .isScaleDownInCooldown (time .Now ()), test .scaleDownInCoolDown )
2686
2695
2687
2696
err := autoscaler .RunOnce (time .Now ())
2688
2697
2689
2698
assert .NoError (t , err )
2690
- candidates , _ := autoscaler .processors .ScaleDownNodeProcessor .GetScaleDownCandidates (autoscaler .AutoscalingContext , test .testNodes )
2691
- assert .Equal (t , test .expectedScaleDownCoolDown , autoscaler .isScaleDownInCooldown (time .Now (), candidates ))
2692
2699
2693
2700
assertNodesSoftTaintsStatus (t , fakeClient , test .expectedNodesWithSoftTaints , true )
2694
2701
assertNodesSoftTaintsStatus (t , fakeClient , test .expectedNodesWithNoSoftTaints , false )
0 commit comments