Skip to content

Commit

Permalink
Merge pull request kubernetes-retired#649 from hex108/preempt
Browse files Browse the repository at this point in the history
Preempt lowest priority task first
  • Loading branch information
k8s-ci-robot authored Mar 25, 2019
2 parents 6174a5a + 4f59c47 commit 7e5dec1
Showing 1 changed file with 9 additions and 2 deletions.
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

0 comments on commit 7e5dec1

Please sign in to comment.