mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Fix an issue that pod may be added to backoffQ
This commit is contained in:
parent
c36127e330
commit
0f66366aff
@ -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.
|
// isPodBackingoff returns true if a pod is still waiting for its backoff timer.
|
||||||
// If this returns true, the pod should not be re-tried.
|
// If this returns true, the pod should not be re-tried.
|
||||||
func (p *PriorityQueue) isPodBackingoff(podInfo *framework.QueuedPodInfo) bool {
|
func (p *PriorityQueue) isPodBackingoff(podInfo *framework.QueuedPodInfo) bool {
|
||||||
|
if podInfo.Gated {
|
||||||
|
return false
|
||||||
|
}
|
||||||
boTime := p.getBackoffTime(podInfo)
|
boTime := p.getBackoffTime(podInfo)
|
||||||
return boTime.After(p.clock.Now())
|
return boTime.After(p.clock.Now())
|
||||||
}
|
}
|
||||||
|
@ -512,14 +512,24 @@ func TestPriorityQueue_addToActiveQ(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
m := map[string][]framework.PreEnqueuePlugin{"": tt.plugins}
|
m := map[string][]framework.PreEnqueuePlugin{"": tt.plugins}
|
||||||
q := NewTestQueueWithObjects(ctx, newDefaultQueueSort(), []runtime.Object{tt.pod}, WithPreEnqueuePluginMap(m))
|
q := NewTestQueueWithObjects(ctx, newDefaultQueueSort(), []runtime.Object{tt.pod}, WithPreEnqueuePluginMap(m),
|
||||||
got, _ := q.addToActiveQ(newQueuedPodInfoForLookup(tt.pod))
|
WithPodInitialBackoffDuration(time.Second*30), WithPodMaxBackoffDuration(time.Second*60))
|
||||||
|
got, _ := q.addToActiveQ(q.newQueuedPodInfo(tt.pod))
|
||||||
if got != tt.wantSuccess {
|
if got != tt.wantSuccess {
|
||||||
t.Errorf("Unexpected result: want %v, but got %v", tt.wantSuccess, got)
|
t.Errorf("Unexpected result: want %v, but got %v", tt.wantSuccess, got)
|
||||||
}
|
}
|
||||||
if tt.wantUnschedulablePods != len(q.unschedulablePods.podInfoMap) {
|
if tt.wantUnschedulablePods != len(q.unschedulablePods.podInfoMap) {
|
||||||
t.Errorf("Unexpected unschedulablePods: want %v, but got %v", 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))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user