Skip to content

Commit

Permalink
Add detailed description of predicate function optimization
Browse files Browse the repository at this point in the history
Signed-off-by: wangyang <wangyang8126@gmail.com>
  • Loading branch information
wangyang0616 committed Jun 29, 2023
1 parent 461742b commit 4058273
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions docs/design/predicate/Predicate-supports-preemption.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## Problem phenomenon:
Related issue: [Reclaim is not working with GPUSharingEnable if resource used is volcano.sh/gpu-memory #2739](https://github.com/volcano-sh/volcano/issues/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.
1. The original predicateFn function handles node immutable (non-preemptive) resources, such as: taint toleration, node affinity, volume zone, numaaware, etc.
1. The allocate and backfile phases execute predicateFn and predicateResourceFn, which are unchanged from the original logic
1. 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](https://github.com/volcano-sh/volcano/pull/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)
1. 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.
1. `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](https://github.com/volcano-sh/volcano/pull/2916)

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

## After comprehensive consideration, `Solution 2` is more suitable

0 comments on commit 4058273

Please sign in to comment.