Skip to content

Commit

Permalink
Merge pull request #3209 from Lily922/release-1.8-2
Browse files Browse the repository at this point in the history
[cherry-pick for release-1.8]support preempting task with bound status
  • Loading branch information
volcano-sh-bot authored Nov 22, 2023
2 parents 43e368b + f8d7324 commit 8c5ab33
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.PreemptableStatus(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.PreemptableStatus(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
}

// PreemptableStatus checks whether the task can be preempted
func PreemptableStatus(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 8c5ab33

Please sign in to comment.