Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions cluster-autoscaler/core/static_autoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2748,28 +2748,35 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
tests := []struct {
name string
testNodes []*apiv1.Node
expectedScaleDownCoolDown bool
scaleDownInCoolDown bool
expectedNodesWithSoftTaints []*apiv1.Node
expectedNodesWithNoSoftTaints []*apiv1.Node
}{
{
name: "Soft tainted nodes are cleaned in case of scale down is in cool down",
name: "Soft tainted nodes are cleaned when scale down skipped",
testNodes: nodesToHaveNoTaints,
expectedScaleDownCoolDown: true,
scaleDownInCoolDown: false,
expectedNodesWithSoftTaints: []*apiv1.Node{},
expectedNodesWithNoSoftTaints: nodesToHaveNoTaints,
},
{
name: "Soft tainted nodes are not cleaned in case of scale down isn't in cool down",
name: "Soft tainted nodes are cleaned when scale down in cooldown",
testNodes: nodesToHaveNoTaints,
scaleDownInCoolDown: true,
expectedNodesWithSoftTaints: []*apiv1.Node{},
expectedNodesWithNoSoftTaints: nodesToHaveNoTaints,
},
{
name: "Soft tainted nodes are not cleaned when scale down requested",
testNodes: nodesToHaveTaints,
expectedScaleDownCoolDown: false,
scaleDownInCoolDown: false,
expectedNodesWithSoftTaints: nodesToHaveTaints,
expectedNodesWithNoSoftTaints: []*apiv1.Node{},
},
{
name: "Soft tainted nodes are cleaned only from min sized node group in case of scale down isn't in cool down",
name: "Soft tainted nodes are cleaned only from min sized node group when scale down requested",
testNodes: append(nodesToHaveNoTaints, nodesToHaveTaints...),
expectedScaleDownCoolDown: false,
scaleDownInCoolDown: false,
expectedNodesWithSoftTaints: nodesToHaveTaints,
expectedNodesWithNoSoftTaints: nodesToHaveNoTaints,
},
Expand All @@ -2780,13 +2787,12 @@ func TestCleaningSoftTaintsInScaleDown(t *testing.T) {
fakeClient := buildFakeClient(t, test.testNodes...)

autoscaler := buildStaticAutoscaler(t, provider, test.testNodes, test.testNodes, fakeClient)
autoscaler.processorCallbacks.disableScaleDownForLoop = test.scaleDownInCoolDown
assert.Equal(t, autoscaler.isScaleDownInCooldown(time.Now()), test.scaleDownInCoolDown)

err := autoscaler.RunOnce(time.Now())

assert.NoError(t, err)
candidates, _ := autoscaler.processors.ScaleDownNodeProcessor.GetScaleDownCandidates(autoscaler.AutoscalingContext, test.testNodes)
assert.Equal(t, test.expectedScaleDownCoolDown, autoscaler.isScaleDownInCooldown(time.Now(), candidates))

assertNodesSoftTaintsStatus(t, fakeClient, test.expectedNodesWithSoftTaints, true)
assertNodesSoftTaintsStatus(t, fakeClient, test.expectedNodesWithNoSoftTaints, false)
})
Expand Down
Loading