Merge pull request #73078 from Huang-Wei/escaped-pod

scheduler: makes pod less racing so as to be put back into activeQ properly
pull/564/head
Kubernetes Prow Robot 2019-01-22 23:34:22 -08:00 committed by GitHub
commit 0b8566f388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

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