Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry-pick for release-1.8]support preempting task with bound status #3209

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
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
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
Loading