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

Refactor PredicateFn for allocate and preempt actions #2916

Merged

Conversation

wangyang0616
Copy link
Member

@wangyang0616 wangyang0616 commented Jun 15, 2023

fix: #2739

Problem phenomenon:

Related issue: Reclaim is not working with GPUSharingEnable if resource used is volcano.sh/gpu-memory #2739

Submit low-priority jobs to occupy all the GPU resources of the cluster, and submit high-priority jobs to request GPU resources.

  • Expectation: High-priority jobs trigger preemption and run successfully, while some low-priority jobs are evicted and become pending;
  • Actual result: The high-priority job does not trigger the preemption action and remains in the pending state;

problem causes:

The scheduling process requires advanced node filtering and then optimization. The corresponding processes in Volcano are predicate and nodeorder, and preemption also needs to go through these two stages. In the predicate stage, each plug-in will be called to implement predicateFn to filter nodes. If a plug-in judges that the node does not meet the scheduling requirements and returns an error, the node will be filtered out.

When vgpu's predicateFn (FilterNode) performs node filtering judgment, it judges the remaining gpu resources of the node. If the remaining resources do not meet the pod scheduling, an error will be reported. This implementation is reasonable for allocate, but in preempt scenarios, judgment The logic of whether a pod can be scheduled to a node is whether the full resources of the node can satisfy pod scheduling, not the remaining resources, which causes this problem.

Extended troubleshooting for similar issues:

In addition to the above-mentioned problems in the vgpu resource, check the implementation of other resources and plug-ins, and find that similar problems exist in many places, for example: the predicate-plugin has an upper limit on the number of pods supported by the filtering node node; it is compatible with kube-scheduler-related Filter functions Filtering logic, node port, pod affinity, node volume, pod topology spread, etc. all have similar problems, and it is necessary to provide a general solution to fix the above problems.

Fix:

Solution 1:

Split the predicate function, and classify the resources that can be preempted and the resources that cannot be preempted. The details are as follows:

  1. The predicateResourceFn function is added, and the logical judgment of dynamically changing (preemptible) resources is unified in the function processing, including: remaining resources of gpu, remaining schedulable pod quantity of node, ports supported by node, volume, pod topology spread, usage, etc.
  2. The original predicateFn function handles node immutable (non-preemptive) resources, such as: taint toleration, node affinity, volume zone, numaaware, etc.
  3. The allocate and backfile phases execute predicateFn and predicateResourceFn, which are unchanged from the original logic
  4. Preempt and reclaim execute predicatFn, and when the node is filtered, it is judged that the node is immutable resource, so the above problem can be solved

The pr corresponding to this program: Split the predicate function to solve the resource filtering problem encountered during preemption #2818

shortcoming:

Splitting the predicate function requires exposing too many filtering functions, the semantic distinction is not clear enough, and it is difficult for development and users to understand and maintain

Solution 2:

Extend the return value type of the predicate and add the Status type, indicating that after the node is filtered, scheduling, preemption is allowed, or preemption is not allowed. The details are as follows:

  1. Add status, the status value is Success, Error, Unschedulable, UnschedulableAndUnresolvable, Wait, Skip, etc. (refer to and be compatible with the processing mode of Filter in kube-scheduler)
  2. Micro-refactor the predicate function in each plug-in, allowing to return Unschedulable when preempted resources are insufficient, and returning UnschedulableAndUnresolvable when preempted resources are not allowed.
  3. allocate and backfill accept nodes whose predicate status is Success, and preempt and reclaim accept nodes whose predicate status is Success and Unschedulable.

This scheme corresponds to pr: Predicate adapts allocate and preempt #2916

advantage:

  1. No need to add a new predicate interface, all filtering logic is completed in one function, and the logic processing is more elegant
  2. Compatible with kube-scheduler plug-in filter capabilities, more convenient to expand

After comprehensive consideration, Solution 2 is more suitable

@volcano-sh-bot volcano-sh-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 15, 2023
@wangyang0616 wangyang0616 force-pushed the feature_predicate_suport_preempt branch 3 times, most recently from f015bec to 39d87b0 Compare June 16, 2023 02:13
@william-wang william-wang changed the title Predicate adapts allocate and preempt [WIP]Predicate adapts allocate and preempt Jun 16, 2023
@volcano-sh-bot volcano-sh-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 16, 2023
@@ -96,13 +97,22 @@ func (alloc *Action) Execute(ssn *framework.Session) {
pendingTasks := map[api.JobID]*util.PriorityQueue{}

allNodes := ssn.NodeList
predicateFn := func(task *api.TaskInfo, node *api.NodeInfo) error {
predicateFn := func(task *api.TaskInfo, node *api.NodeInfo) ([]*api.Status, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wangyang0616 Whether it is enough to use *api.Status?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The predicate plugin integrates multiple filter plug-ins of kube-scheduler. It is necessary to collect the filtering results of each plug-in and judge on the action side.

At present, it is necessary to return the list list. If there is a more elegant solution in the future, we can use it in optimize.

return api.NewFitError(task, node, reason)
return nil, api.NewFitError(task, node, reason)
}
predicateStatus, err := ssn.PredicateFn(task, node)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to make the action code clear and short.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review, here is mainly the core logic that distinguishes the difference between allocate and preempt. It has been modified using the previous logical architecture.

I will consider it later to see if it can be further optimized.

@wangyang0616 wangyang0616 force-pushed the feature_predicate_suport_preempt branch 2 times, most recently from aa31812 to a4600b8 Compare June 16, 2023 07:40
@wangyang0616 wangyang0616 changed the title [WIP]Predicate adapts allocate and preempt Predicate adapts allocate and preempt Jun 16, 2023
@volcano-sh-bot volcano-sh-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 16, 2023
}
for _, status := range predicateStatus {
if status != nil && status.Code != api.Success {
return nil, api.NewFitError(task, node, status.Reason)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just return the first failure?

@@ -250,4 +254,32 @@ func (alloc *Action) Execute(ssn *framework.Session) {
}
}

func prePredicateforAllocate(ssn *framework.Session, task *api.TaskInfo, allNodes []*api.NodeInfo, job *api.JobInfo) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prePredicateforAllolcate is similar with prePredicateforBackfill and prePredicateforReclaim

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -101,4 +96,45 @@ func (backfill *Action) Execute(ssn *framework.Session) {
}
}

func predicateforBackfill(ssn *framework.Session, task *api.TaskInfo, node *api.NodeInfo, fe *api.FitErrors) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we consolidate the predicateforBackfill, predicateforReclaim, predicateforAllocate and predicateforPrempt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@volcano-sh-bot volcano-sh-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 19, 2023
@wangyang0616 wangyang0616 changed the title Predicate adapts allocate and preempt [WIP]Predicate adapts allocate and preempt Jun 21, 2023
@volcano-sh-bot volcano-sh-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 21, 2023
@william-wang
Copy link
Member

@Yikun Would you please have a look at the spark failure?

@Yikun
Copy link
Member

Yikun commented Jun 26, 2023

@Yikun Would you please have a look at the spark failure?

It should be fixed by upgrading spark repo to 3.4, lets see results: #2934

@wangyang0616 wangyang0616 force-pushed the feature_predicate_suport_preempt branch 2 times, most recently from 94124f7 to 461742b Compare June 27, 2023 14:25
@wangyang0616 wangyang0616 changed the title [WIP]Predicate adapts allocate and preempt Predicate adapts allocate and preempt Jun 27, 2023
@volcano-sh-bot volcano-sh-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 27, 2023
@wangyang0616 wangyang0616 force-pushed the feature_predicate_suport_preempt branch from 4058273 to 8e060d9 Compare June 29, 2023 08:42
@wangyang0616 wangyang0616 force-pushed the feature_predicate_suport_preempt branch 3 times, most recently from f1d8522 to 886e438 Compare July 12, 2023 11:06
@@ -107,3 +107,47 @@ func taskGroupID(task *api.TaskInfo) string {
func NewPredicateHelper() PredicateHelper {
return &predicateHelper{taskPredicateErrorCache: map[string]map[string]error{}}
}

type PredicateStatus interface {
IsContainsUnschedulable() bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IsContainsUnschedulable is inconsistent with implementation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's supposed to be deleted here, done.

task.Namespace, task.Name, node.Name, err)
fe.SetNodeError(node.Name, err)
continue
}

if statusSets.ContainsUnschedulable() || statusSets.ContainsUnschedulableAndUnresolvable() ||
statusSets.ContainsErrorSkipOrWait() {
err := fmt.Errorf("predicates failed in backfill for task <%s/%s> on node <%s>, status is not success",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please combine line #89 and #90

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to generate the errors structure. The log output has been updated.

var statusSets util.StatusSets
statusSets, err := ssn.PredicateFn(task, node)
if err != nil {
klog.V(3).Infof("backfill predicates failed for task <%s/%s> on node <%s>: %v",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make the log clear for user. for example. change the backfill predicates failed xxx to predicate failed in backfill action xxx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@wangyang0616 wangyang0616 changed the title Predicate adapts allocate and preempt Refactor PredicateFn for allocate and preempt actions Jul 12, 2023
Copy link
Member

@william-wang william-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@william-wang
Copy link
Member

/lgtm

1 similar comment
@jiangkaihua
Copy link
Contributor

/lgtm

@wangyang0616 wangyang0616 force-pushed the feature_predicate_suport_preempt branch from 0683e75 to cb8a186 Compare July 13, 2023 06:36
@volcano-sh-bot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 13, 2023
@william-wang
Copy link
Member

The proboot issue is fixed and need to mark the lgtm again.

@william-wang
Copy link
Member

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reclaim is not working with GPUSharingEnable if resource used is volcano.sh/gpu-memory
5 participants