Skip to content

Commit

Permalink
[YUNIKORN-2068] Fix deadlock when evaluating preemption candidates (#697
Browse files Browse the repository at this point in the history
)

Closes: #697
  • Loading branch information
craigcondit committed Oct 23, 2023
1 parent dc7794a commit 04e9340
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/cache/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pkg/cache/external/scheduler_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 04e9340

Please sign in to comment.