From 157903b09b63c96157d6c43ad130ff907fb3948b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Skocze=C5=84?= Date: Mon, 26 May 2025 09:35:53 +0000 Subject: [PATCH] Skip backoff when PodMaxBackoffDuration is set to zero --- pkg/scheduler/backend/queue/backoff_queue.go | 4 ++++ pkg/scheduler/backend/queue/backoff_queue_test.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/pkg/scheduler/backend/queue/backoff_queue.go b/pkg/scheduler/backend/queue/backoff_queue.go index 733f41adcd5..0ad7f478680 100644 --- a/pkg/scheduler/backend/queue/backoff_queue.go +++ b/pkg/scheduler/backend/queue/backoff_queue.go @@ -218,6 +218,10 @@ func (bq *backoffQueue) isPodBackingoff(podInfo *framework.QueuedPodInfo) bool { // because of the fact that the backoff time is calculated based on podInfo.Attempts, // which doesn't get changed until the pod's scheduling is retried. func (bq *backoffQueue) getBackoffTime(podInfo *framework.QueuedPodInfo) time.Time { + if bq.podMaxBackoff == 0 { + // If podMaxBackoff is set to 0, the backoff should be disabled completely. + return time.Time{} + } count := podInfo.UnschedulableCount if podInfo.ConsecutiveErrorsCount > 0 { // This Pod has experienced an error status at the last scheduling cycle, diff --git a/pkg/scheduler/backend/queue/backoff_queue_test.go b/pkg/scheduler/backend/queue/backoff_queue_test.go index 3b5122889e1..078f6853ddf 100644 --- a/pkg/scheduler/backend/queue/backoff_queue_test.go +++ b/pkg/scheduler/backend/queue/backoff_queue_test.go @@ -67,6 +67,13 @@ func TestBackoffQueue_getBackoffTime(t *testing.T) { podInfo: &framework.QueuedPodInfo{UnschedulableCount: 5, ConsecutiveErrorsCount: 16, Timestamp: time.Date(2023, 10, 1, 0, 0, 0, 0, time.UTC)}, want: time.Date(2023, 10, 1, 0, 0, 32, 0, time.UTC), }, + { + name: "zero maxBackoffDuration means no backoff", + initialBackoffDuration: 0, + maxBackoffDuration: 0, + podInfo: &framework.QueuedPodInfo{UnschedulableCount: 16, Timestamp: time.Date(2023, 10, 1, 0, 0, 0, 0, time.UTC)}, + want: time.Time{}, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {