-
Notifications
You must be signed in to change notification settings - Fork 963
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
Changes from all commits
7bee28e
24ad50e
17eeca5
1d22455
b3ac598
cb8a186
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,15 @@ limitations under the License. | |
package backfill | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"k8s.io/klog/v2" | ||
|
||
"volcano.sh/volcano/pkg/scheduler/api" | ||
"volcano.sh/volcano/pkg/scheduler/framework" | ||
"volcano.sh/volcano/pkg/scheduler/metrics" | ||
"volcano.sh/volcano/pkg/scheduler/util" | ||
) | ||
|
||
type Action struct{} | ||
|
@@ -72,13 +74,25 @@ func (backfill *Action) Execute(ssn *framework.Session) { | |
for _, node := range ssn.Nodes { | ||
// TODO (k82cn): predicates did not consider pod number for now, there'll | ||
// be ping-pong case here. | ||
if err := ssn.PredicateFn(task, node); err != nil { | ||
klog.V(3).Infof("Predicates failed for task <%s/%s> on node <%s>: %v", | ||
// Only nodes whose status is success after predicate filtering can be scheduled. | ||
var statusSets util.StatusSets | ||
statusSets, err := ssn.PredicateFn(task, node) | ||
if err != nil { | ||
klog.V(3).Infof("predicates failed in backfill for task <%s/%s> on node <%s>: %v", | ||
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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
task.Namespace, task.Name, node.Name) | ||
klog.V(3).Infof("%v", err) | ||
fe.SetNodeError(node.Name, err) | ||
continue | ||
} | ||
|
||
klog.V(3).Infof("Binding Task <%v/%v> to node <%v>", task.Namespace, task.Name, node.Name) | ||
if err := ssn.Allocate(task, node); err != nil { | ||
klog.Errorf("Failed to bind Task %v on %v in Session %v", task.UID, node.Name, ssn.UID) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package devices | ||
|
||
// These are predefined codes used in a Status. | ||
const ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These same status are defined in device package and api package. Is it possible to combine two to one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Volcano API package references the devices package. If the status definition in the API is used, cyclic dependency occurs. |
||
// Success means that plugin ran correctly and found pod schedulable. | ||
// NOTE: A nil status is also considered as "Success". | ||
Success int = iota | ||
// Error is used for internal plugin errors, unexpected input, etc. | ||
Error | ||
// Unschedulable is used when a plugin finds a pod unschedulable. The scheduler might attempt to | ||
// preempt other pods to get this pod scheduled. Use UnschedulableAndUnresolvable to make the | ||
// scheduler skip preemption. | ||
// The accompanying status message should explain why the pod is unschedulable. | ||
Unschedulable | ||
// UnschedulableAndUnresolvable is used when a plugin finds a pod unschedulable and | ||
// preemption would not change anything. Plugins should return Unschedulable if it is possible | ||
// that the pod can get scheduled with preemption. | ||
// The accompanying status message should explain why the pod is unschedulable. | ||
UnschedulableAndUnresolvable | ||
// Wait is used when a Permit plugin finds a pod scheduling should wait. | ||
Wait | ||
// Skip is used when a Bind plugin chooses to skip binding. | ||
Skip | ||
) |
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.
@wangyang0616 Whether it is enough to use
*api.Status
?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.
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.