diff --git a/pkg/scheduler/internal/queue/scheduling_queue.go b/pkg/scheduler/internal/queue/scheduling_queue.go index 5332e00d661..4e3cf633597 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue.go +++ b/pkg/scheduler/internal/queue/scheduling_queue.go @@ -441,6 +441,9 @@ func (p *PriorityQueue) activate(pod *v1.Pod) bool { // isPodBackingoff returns true if a pod is still waiting for its backoff timer. // If this returns true, the pod should not be re-tried. func (p *PriorityQueue) isPodBackingoff(podInfo *framework.QueuedPodInfo) bool { + if podInfo.Gated { + return false + } boTime := p.getBackoffTime(podInfo) return boTime.After(p.clock.Now()) } diff --git a/pkg/scheduler/internal/queue/scheduling_queue_test.go b/pkg/scheduler/internal/queue/scheduling_queue_test.go index 95062a43274..e90ef891773 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue_test.go +++ b/pkg/scheduler/internal/queue/scheduling_queue_test.go @@ -512,14 +512,24 @@ func TestPriorityQueue_addToActiveQ(t *testing.T) { defer cancel() m := map[string][]framework.PreEnqueuePlugin{"": tt.plugins} - q := NewTestQueueWithObjects(ctx, newDefaultQueueSort(), []runtime.Object{tt.pod}, WithPreEnqueuePluginMap(m)) - got, _ := q.addToActiveQ(newQueuedPodInfoForLookup(tt.pod)) + q := NewTestQueueWithObjects(ctx, newDefaultQueueSort(), []runtime.Object{tt.pod}, WithPreEnqueuePluginMap(m), + WithPodInitialBackoffDuration(time.Second*30), WithPodMaxBackoffDuration(time.Second*60)) + got, _ := q.addToActiveQ(q.newQueuedPodInfo(tt.pod)) if got != tt.wantSuccess { t.Errorf("Unexpected result: want %v, but got %v", tt.wantSuccess, got) } if tt.wantUnschedulablePods != len(q.unschedulablePods.podInfoMap) { t.Errorf("Unexpected unschedulablePods: want %v, but got %v", tt.wantUnschedulablePods, len(q.unschedulablePods.podInfoMap)) } + + // Simulate an update event. + clone := tt.pod.DeepCopy() + metav1.SetMetaDataAnnotation(&clone.ObjectMeta, "foo", "") + q.Update(tt.pod, clone) + // Ensure the pod is still located in unschedulablePods. + if tt.wantUnschedulablePods != len(q.unschedulablePods.podInfoMap) { + t.Errorf("Unexpected unschedulablePods: want %v, but got %v", tt.wantUnschedulablePods, len(q.unschedulablePods.podInfoMap)) + } }) } }