Merge pull request #126222 from macsko/dont_lock_activeq_twice_in_activate_in_scheduling_queue

Don't lock activeQ twice when activating pod in scheduling queue
This commit is contained in:
Kubernetes Prow Robot 2024-07-19 12:03:10 -07:00 committed by GitHub
commit 6f3f115378
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -660,17 +660,12 @@ func (p *PriorityQueue) existsInActiveQ(pInfo *framework.QueuedPodInfo) bool {
} }
func (p *PriorityQueue) activate(logger klog.Logger, pod *v1.Pod) bool { func (p *PriorityQueue) activate(logger klog.Logger, pod *v1.Pod) bool {
// Verify if the pod is present in activeQ.
if p.existsInActiveQ(newQueuedPodInfoForLookup(pod)) {
// No need to activate if it's already present in activeQ.
return false
}
var pInfo *framework.QueuedPodInfo var pInfo *framework.QueuedPodInfo
// Verify if the pod is present in unschedulablePods or backoffQ. // Verify if the pod is present in unschedulablePods or backoffQ.
if pInfo = p.unschedulablePods.get(pod); pInfo == nil { if pInfo = p.unschedulablePods.get(pod); pInfo == nil {
// If the pod doesn't belong to unschedulablePods or backoffQ, don't activate it. // If the pod doesn't belong to unschedulablePods or backoffQ, don't activate it.
// The pod can be already in activeQ.
if obj, exists, _ := p.podBackoffQ.Get(newQueuedPodInfoForLookup(pod)); !exists { if obj, exists, _ := p.podBackoffQ.Get(newQueuedPodInfoForLookup(pod)); !exists {
logger.Error(nil, "To-activate pod does not exist in unschedulablePods or backoffQ", "pod", klog.KObj(pod))
return false return false
} else { } else {
pInfo = obj.(*framework.QueuedPodInfo) pInfo = obj.(*framework.QueuedPodInfo)