mirror of https://github.com/k3s-io/k3s
Merge pull request #73078 from Huang-Wei/escaped-pod
scheduler: makes pod less racing so as to be put back into activeQ properlypull/564/head
commit
0b8566f388
|
@ -376,7 +376,7 @@ func (p *PriorityQueue) backoffPod(pod *v1.Pod) {
|
||||||
// queue. If pod is unschedulable, it adds pod to unschedulable queue if
|
// queue. If pod is unschedulable, it adds pod to unschedulable queue if
|
||||||
// p.receivedMoveRequest is false or to backoff queue if p.receivedMoveRequest
|
// p.receivedMoveRequest is false or to backoff queue if p.receivedMoveRequest
|
||||||
// is true but pod is subject to backoff. In other cases, it adds pod to active
|
// is true but pod is subject to backoff. In other cases, it adds pod to active
|
||||||
// queue.
|
// queue and clears p.receivedMoveRequest.
|
||||||
func (p *PriorityQueue) AddUnschedulableIfNotPresent(pod *v1.Pod) error {
|
func (p *PriorityQueue) AddUnschedulableIfNotPresent(pod *v1.Pod) error {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
|
@ -412,6 +412,7 @@ func (p *PriorityQueue) AddUnschedulableIfNotPresent(pod *v1.Pod) error {
|
||||||
p.nominatedPods.add(pod, "")
|
p.nominatedPods.add(pod, "")
|
||||||
p.cond.Broadcast()
|
p.cond.Broadcast()
|
||||||
}
|
}
|
||||||
|
p.receivedMoveRequest = false
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,8 +470,7 @@ func (p *PriorityQueue) flushUnschedulableQLeftover() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pop removes the head of the active queue and returns it. It blocks if the
|
// Pop removes the head of the active queue and returns it. It blocks if the
|
||||||
// activeQ is empty and waits until a new item is added to the queue. It also
|
// activeQ is empty and waits until a new item is added to the queue.
|
||||||
// clears receivedMoveRequest to mark the beginning of a new scheduling cycle.
|
|
||||||
func (p *PriorityQueue) Pop() (*v1.Pod, error) {
|
func (p *PriorityQueue) Pop() (*v1.Pod, error) {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
|
@ -488,7 +488,6 @@ func (p *PriorityQueue) Pop() (*v1.Pod, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pod := obj.(*v1.Pod)
|
pod := obj.(*v1.Pod)
|
||||||
p.receivedMoveRequest = false
|
|
||||||
return pod, err
|
return pod, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue