Skip to content

Commit

Permalink
support preempting task with bound status
Browse files Browse the repository at this point in the history
Signed-off-by: lili <lili_9309@163.com>
  • Loading branch information
Lily922 committed Nov 16, 2023
1 parent 5683dbe commit 8093238
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/scheduler/actions/preempt/preempt.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (pmpt *Action) Execute(ssn *framework.Session) {

if preempted, _ := preempt(ssn, stmt, preemptor, func(task *api.TaskInfo) bool {
// Ignore non running task.
if task.Status != api.Running {
if !api.PreemptibleStatus(task.Status) {
return false
}
// Ignore task with empty resource request.
Expand Down Expand Up @@ -169,7 +169,7 @@ func (pmpt *Action) Execute(ssn *framework.Session) {
stmt := framework.NewStatement(ssn)
assigned, _ := preempt(ssn, stmt, preemptor, func(task *api.TaskInfo) bool {
// Ignore non running task.
if task.Status != api.Running {
if !api.PreemptibleStatus(task.Status) {
return false
}
// Ignore task with empty resource request.
Expand Down
10 changes: 10 additions & 0 deletions pkg/scheduler/api/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ func getTaskStatus(pod *v1.Pod) TaskStatus {
return Unknown
}

// PreemptibleStatus checks whether the task can be preempted
func PreemptibleStatus(status TaskStatus) bool {
switch status {
case Bound, Running:
return true
default:
return false
}
}

// AllocatedStatus checks whether the tasks has AllocatedStatus
func AllocatedStatus(status TaskStatus) bool {
switch status {
Expand Down

0 comments on commit 8093238

Please sign in to comment.