Skip backoff when PodMaxBackoffDuration is set to zero

This commit is contained in:
Maciej Skoczeń
2025-05-26 09:35:53 +00:00
parent 3044a4ce87
commit 157903b09b
2 changed files with 11 additions and 0 deletions

View File

@@ -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,

View File

@@ -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) {