Skip to content

Commit

Permalink
skip check ssn.Allocatable in reclaim action and add preemptiveFn in …
Browse files Browse the repository at this point in the history
…proportion plugin

Signed-off-by: bogo_y <[email protected]>
Co-authored-by: Monokaix <[email protected]>
  • Loading branch information
bogo-y and Monokaix committed Jan 6, 2025
1 parent 29c8027 commit 61f9c9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 2 additions & 5 deletions pkg/scheduler/actions/reclaim/reclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,8 @@ func (ra *Action) Execute(ssn *framework.Session) {
continue
}

if !ssn.Allocatable(queue, task) {
klog.V(3).Infof("Queue <%s> is overused when considering task <%s>, ignore it.", queue.Name, task.Name)
continue
}

//In allocate action we need check all the ancestor queues' capability but in reclaim action we should just check current queue's capability, and reclaim happens when queue not allocatable so we just need focus on the reclaim here.
//So it's more descriptive to user preempt related semantics.
if !ssn.Preemptive(queue, task) {
klog.V(3).Infof("Queue <%s> can not reclaim by preempt others when considering task <%s> , ignore it.", queue.Name, task.Name)
continue
Expand Down
11 changes: 10 additions & 1 deletion pkg/scheduler/plugins/proportion/proportion.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
return overused
})

ssn.AddAllocatableFn(pp.Name(), func(queue *api.QueueInfo, candidate *api.TaskInfo) bool {
queueAllocatable := func(queue *api.QueueInfo, candidate *api.TaskInfo) bool {
attr := pp.queueOpts[queue.UID]

futureUsed := attr.allocated.Clone().Add(candidate.Resreq)
Expand All @@ -314,6 +314,15 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
}

return allocatable
}

ssn.AddAllocatableFn(pp.Name(), func(queue *api.QueueInfo, candidate *api.TaskInfo) bool {
return queueAllocatable(queue, candidate)
})
ssn.AddPreemptiveFn(pp.Name(), func(obj interface{}, candidate interface{}) bool {
queue := obj.(*api.QueueInfo)
task := candidate.(*api.TaskInfo)
return queueAllocatable(queue, task)
})

ssn.AddJobEnqueueableFn(pp.Name(), func(obj interface{}) int {
Expand Down

0 comments on commit 61f9c9d

Please sign in to comment.