a flag to indicate whether or not to broadcast

change the returns above to breaks, add a flag to indicate whether or not to broadcast.
This commit is contained in:
duc 2022-01-27 21:48:41 +08:00
parent c3bfb568f9
commit 040f8a4cf0

View File

@ -411,23 +411,28 @@ func (p *PriorityQueue) AddUnschedulableIfNotPresent(pInfo *framework.QueuedPodI
func (p *PriorityQueue) flushBackoffQCompleted() {
p.lock.Lock()
defer p.lock.Unlock()
broadcast := false
for {
rawPodInfo := p.podBackoffQ.Peek()
if rawPodInfo == nil {
return
break
}
pod := rawPodInfo.(*framework.QueuedPodInfo).Pod
boTime := p.getBackoffTime(rawPodInfo.(*framework.QueuedPodInfo))
if boTime.After(p.clock.Now()) {
return
break
}
_, err := p.podBackoffQ.Pop()
if err != nil {
klog.ErrorS(err, "Unable to pop pod from backoff queue despite backoff completion", "pod", klog.KObj(pod))
return
break
}
p.activeQ.Add(rawPodInfo)
metrics.SchedulerQueueIncomingPods.WithLabelValues("active", BackoffComplete).Inc()
broadcast = true
}
if broadcast {
p.cond.Broadcast()
}
}