Skip to content

Commit

Permalink
fix some review comments, rename function name to PredicateForXXAction
Browse files Browse the repository at this point in the history
Signed-off-by: lowang-bh <lhui_wang@163.com>
  • Loading branch information
lowang-bh committed Aug 1, 2024
1 parent 2b02a38 commit 2dff5d8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/scheduler/actions/allocate/allocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (alloc *Action) predicate(task *api.TaskInfo, node *api.NodeInfo) error {
statusSets = append(statusSets, &api.Status{Code: api.Unschedulable, Reason: api.WrapInsufficientResourceReason(resources)})
return api.NewFitErrWithStatus(task, node, statusSets...)
}
return alloc.session.PredicateWhenAllocate(task, node)
return alloc.session.PredicateForAllocateAction(task, node)
}

func (alloc *Action) UnInitialize() {}
2 changes: 1 addition & 1 deletion pkg/scheduler/actions/backfill/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (backfill *Action) Execute(ssn *framework.Session) {
klog.V(5).Infof("Enter Backfill ...")
defer klog.V(5).Infof("Leaving Backfill ...")

predicateFunc := ssn.PredicateWhenAllocate
predicateFunc := ssn.PredicateForAllocateAction

// TODO (k82cn): When backfill, it's also need to balance between Queues.
pendingTasks := backfill.pickUpPendingTasks(ssn)
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/actions/preempt/preempt.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func preempt(
return false, fmt.Errorf("PrePredicate for task %s/%s failed for: %v", preemptor.Namespace, preemptor.Name, err)
}

predicateFn := ssn.PredicateWhenPreempt
predicateFn := ssn.PredicateForPreemptAction
// we should filter out those nodes that are UnschedulableAndUnresolvable status got in allocate action
allNodes := ssn.GetUnschedulableAndUnresolvableNodesForTask(preemptor)
predicateNodes, _ := predicateHelper.PredicateNodes(preemptor, allNodes, predicateFn, true)
Expand Down
3 changes: 2 additions & 1 deletion pkg/scheduler/actions/reclaim/reclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func (ra *Action) Execute(ssn *framework.Session) {
for _, n := range totalNodes {
// When filtering candidate nodes, need to consider the node statusSets instead of the err information.
// refer to kube-scheduler preemption code: https://github.com/kubernetes/kubernetes/blob/9d87fa215d9e8020abdc17132d1252536cd752d2/pkg/scheduler/framework/preemption/preemption.go#L422
if err := ssn.PredicateWhenPreempt(task, n); err != nil {
if err := ssn.PredicateForPreemptAction(task, n); err != nil {
klog.V(4).Infof("Reclaim predicate for task %s/%s on node %s return error %v ", task.Namespace, task.Name, n.Name, err)
continue
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/scheduler/framework/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,11 @@ func (ssn *Session) GetUnschedulableAndUnresolvableNodesForTask(task *api.TaskIn
return ret
}

// PredicateWhenAllocate checks if the predicate error contains
// PredicateForAllocateAction checks if the predicate error contains
// - Unschedulable
// - UnschedulableAndUnresolvable
// - ErrorSkipOrWait
func (ssn *Session) PredicateWhenAllocate(task *api.TaskInfo, node *api.NodeInfo) error {
func (ssn *Session) PredicateForAllocateAction(task *api.TaskInfo, node *api.NodeInfo) error {
err := ssn.PredicateFn(task, node)
if err == nil {
return nil
Expand All @@ -336,10 +336,10 @@ func (ssn *Session) PredicateWhenAllocate(task *api.TaskInfo, node *api.NodeInfo
return nil
}

// PredicateWhenPreempt checks if the predicate error contains:
// PredicateForPreemptAction checks if the predicate error contains:
// - UnschedulableAndUnresolvable
// - ErrorSkipOrWait
func (ssn *Session) PredicateWhenPreempt(task *api.TaskInfo, node *api.NodeInfo) error {
func (ssn *Session) PredicateForPreemptAction(task *api.TaskInfo, node *api.NodeInfo) error {
err := ssn.PredicateFn(task, node)
if err == nil {
return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/plugins/extender/extender.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ func (ep *extenderPlugin) OnSessionOpen(ssn *framework.Session) {
if len(resp.ErrorMessage) == 0 {
return nil
}
// keep compatibility with old behavior: error messages length is not zero
// but didn't return a code, and code will be 0 for default. Change code to zero for corresponding
// keep compatibility with old behavior: error messages length is not zero,
// but didn't return a code, and code will be 0 for default. Change code to Error for corresponding
if resp.Code == api.Success {
resp.Code = api.Error
}
Expand Down
1 change: 0 additions & 1 deletion pkg/scheduler/plugins/usage/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func (up *usagePlugin) OnSessionOpen(ssn *framework.Session) {
klog.V(4).Infof("The period(%s) is empty or the usage metrics data is not updated for more than %v minutes, "+
"Usage plugin filter for task %s/%s on node %s pass, metrics time is %v. ", up.period, MetricsActiveTime, task.Namespace, task.Name, node.Name, node.ResourceUsage.MetricsTime)

usageStatus.Code = api.Success
return nil
}

Expand Down

0 comments on commit 2dff5d8

Please sign in to comment.