From 57c1c44a8cd4267c5c1be79a68b8fd450d14e452 Mon Sep 17 00:00:00 2001 From: "david.benque" Date: Mon, 21 Jun 2021 15:53:12 +0200 Subject: [PATCH] taint based eviction: allow lengthening eviction schedule --- pkg/controller/nodelifecycle/scheduler/taint_manager.go | 3 ++- pkg/controller/nodelifecycle/scheduler/taint_manager_test.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/controller/nodelifecycle/scheduler/taint_manager.go b/pkg/controller/nodelifecycle/scheduler/taint_manager.go index 8e38578a1a2aa..f5c3385637a01 100644 --- a/pkg/controller/nodelifecycle/scheduler/taint_manager.go +++ b/pkg/controller/nodelifecycle/scheduler/taint_manager.go @@ -368,7 +368,8 @@ func (tc *NoExecuteTaintManager) processPodOnNode( scheduledEviction := tc.taintEvictionQueue.GetWorkerUnsafe(podNamespacedName.String()) if scheduledEviction != nil { startTime = scheduledEviction.CreatedAt - if startTime.Add(minTolerationTime).Before(triggerTime) { + deltaScheduleSeconds:= math.Abs(startTime.Add(minTolerationTime).Sub(scheduledEviction.FireAt).Seconds()) + if deltaScheduleSeconds< 10.0 { // schedule differ by less than 10s, no need to reschedule return } tc.cancelWorkWithEvent(podNamespacedName) diff --git a/pkg/controller/nodelifecycle/scheduler/taint_manager_test.go b/pkg/controller/nodelifecycle/scheduler/taint_manager_test.go index 56009336311d3..664a91afb865b 100644 --- a/pkg/controller/nodelifecycle/scheduler/taint_manager_test.go +++ b/pkg/controller/nodelifecycle/scheduler/taint_manager_test.go @@ -292,13 +292,13 @@ func TestUpdatePod(t *testing.T) { expectDelete: true, }, { - description: "lengthening toleration shouldn't work", + description: "allow lengthening toleration", prevPod: addToleration(testutil.NewPod("pod1", "node1"), 1, 1), newPod: addToleration(testutil.NewPod("pod1", "node1"), 1, 100), taintedNodes: map[string][]v1.Taint{ "node1": {createNoExecuteTaint(1)}, }, - expectDelete: true, + expectDelete: false, additionalSleep: 1500 * time.Millisecond, }, }