From 66d4bd320604a73c978c15109e3c249f040d41d0 Mon Sep 17 00:00:00 2001 From: Manuel Grandeit Date: Sat, 20 Dec 2025 13:34:01 +0100 Subject: [PATCH] Fix data race in PriorityQueue.UnschedulablePods() The UnschedulablePods() function iterates over the unschedulablePods.podInfoMap without holding any lock, while other goroutines may concurrently modify the map via addOrUpdate(), delete(), or clear(). Other functions like PendingPods() and GetPod() correctly acquire p.lock.RLock() before accessing unschedulablePods.podInfoMap, but UnschedulablePods() was missing this. Fix by adding p.lock.RLock()/RUnlock() to UnschedulablePods(), matching the pattern used by PendingPods(). --- pkg/scheduler/backend/queue/scheduling_queue.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/scheduler/backend/queue/scheduling_queue.go b/pkg/scheduler/backend/queue/scheduling_queue.go index 67004e115b8..2e9e5c09b35 100644 --- a/pkg/scheduler/backend/queue/scheduling_queue.go +++ b/pkg/scheduler/backend/queue/scheduling_queue.go @@ -1302,6 +1302,8 @@ func (p *PriorityQueue) PodsInBackoffQ() []*v1.Pod { // UnschedulablePods returns all the pods in unschedulable state. func (p *PriorityQueue) UnschedulablePods() []*v1.Pod { + p.lock.RLock() + defer p.lock.RUnlock() var result []*v1.Pod for _, pInfo := range p.unschedulablePods.podInfoMap { result = append(result, pInfo.Pod)