Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Preempt lowest priority task first #649

Merged
merged 1 commit into from
Mar 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/scheduler/actions/preempt/preempt.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,15 @@ func preempt(
continue
}

// Preempt victims for tasks.
for _, preemptee := range victims {
victimsQueue := util.NewPriorityQueue(func(l, r interface{}) bool {
return !ssn.TaskOrderFn(l, r)
})
for _, victim := range victims {
victimsQueue.Push(victim)
}
// Preempt victims for tasks, pick lowest priority task first.
for !victimsQueue.Empty() {
preemptee := victimsQueue.Pop().(*api.TaskInfo)
glog.Errorf("Try to preempt Task <%s/%s> for Tasks <%s/%s>",
preemptee.Namespace, preemptee.Name, preemptor.Namespace, preemptor.Name)
if err := stmt.Evict(preemptee, "preempt"); err != nil {
Expand Down