-
Notifications
You must be signed in to change notification settings - Fork 974
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
Support preempting BestEffort pods when the pods number of nodes reaches the upper limit #3335
Conversation
Hi, thanks for the contributions. Please add some UTs about your scenario。 |
pkg/scheduler/api/job_info.go
Outdated
for status, tasks := range ji.TaskStatusIndex { | ||
if status == Pending { | ||
for _, task := range tasks { | ||
if task.InitResreq.IsEmpty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already has a BestEffort
flag, don't need to calculate it any more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/scheduler/api/job_info.go
Outdated
@@ -707,6 +699,20 @@ func (ji *JobInfo) WaitingTaskNum() int32 { | |||
return int32(len(ji.TaskStatusIndex[Pipelined])) | |||
} | |||
|
|||
func (ji *JobInfo) PendingBestEffortTaskNum() int32 { | |||
count := 0 | |||
for status, tasks := range ji.TaskStatusIndex { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my opinion, we can directly check ji.TaskStatusIndex[Pending]
and sum up the count.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
job.NodesFitErrors[task.UID] = fe | ||
break | ||
} | ||
if !task.InitResreq.IsEmpty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use task.BestEffort
property directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
d08ed78
to
a66a7fa
Compare
done |
for _, job := range tc.jobs { | ||
jobInfo := api.NewJobInfo(job.uid, job.tasks...) | ||
jobInfo.Queue = "queue-1" | ||
jobInfo.PodGroup = &api.PodGroup{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use BuildXX function in pkg/scheduler/util/test_utils.go
to gen those basic node/pg/queue to clean code.
And use NewDefaultMockSchedulerCache
in pkg/scheduler/cache/cache_mock.go
to gen the SchedulerCache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -117,8 +117,8 @@ func (pmpt *Action) Execute(ssn *framework.Session) { | |||
if !api.PreemptableStatus(task.Status) { | |||
return false | |||
} | |||
// Ignore task with empty resource request. | |||
if task.Resreq.IsEmpty() { | |||
// BestEffort pod is not supported to preempt unBestEffort pod. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a besteffort pod has a higher priority, preemption will not happen, is this expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a besteffort pod has a higher priority, preemption will not happen, is this expected?
yes, besteffort pod will be scheduled in "backfill" action, unbesteffort pods will be scheduled in "allocate" action. In normal use, allocate is executed before backfill, the preempted pod will be scheduled first in the next scheduler cycle
pkg/scheduler/api/job_info_test.go
Outdated
@@ -17,14 +17,16 @@ limitations under the License. | |||
package api | |||
|
|||
import ( | |||
"k8s.io/apimachinery/pkg/api/resource" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort imports.
done
…hes the upper limit Signed-off-by: lili <[email protected]>
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: william-wang The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
fix #3336
Design:
Ignore pending BestEffort pods when checking if the Job is starving.