diff --git a/pkg/cache/context.go b/pkg/cache/context.go index d3488bc10..a255e78d6 100644 --- a/pkg/cache/context.go +++ b/pkg/cache/context.go @@ -474,7 +474,7 @@ func (ctx *Context) IsPodFitNodeViaPreemption(name, node string, allocations []s // look up each victim in the scheduler cache victims := make([]*v1.Pod, 0) for _, uid := range allocations { - if victim, ok := ctx.schedulerCache.GetPod(uid); ok { + if victim, ok := ctx.schedulerCache.GetPodNoLock(uid); ok { victims = append(victims, victim) } else { // if pod isn't found, add a placeholder so that the list is still the same size diff --git a/pkg/cache/external/scheduler_cache.go b/pkg/cache/external/scheduler_cache.go index 3a4434e74..aaf063f51 100644 --- a/pkg/cache/external/scheduler_cache.go +++ b/pkg/cache/external/scheduler_cache.go @@ -471,6 +471,10 @@ func (cache *SchedulerCache) removePod(pod *v1.Pod) { func (cache *SchedulerCache) GetPod(uid string) (*v1.Pod, bool) { cache.lock.RLock() defer cache.lock.RUnlock() + return cache.GetPodNoLock(uid) +} + +func (cache *SchedulerCache) GetPodNoLock(uid string) (*v1.Pod, bool) { if pod, ok := cache.podsMap[uid]; ok { return pod, true }