diff --git a/pkg/scheduler/actions/allocate/allocate.go b/pkg/scheduler/actions/allocate/allocate.go index 6771a431473..43627197673 100644 --- a/pkg/scheduler/actions/allocate/allocate.go +++ b/pkg/scheduler/actions/allocate/allocate.go @@ -17,6 +17,7 @@ package allocate import ( + "fmt" "time" "k8s.io/klog/v2" @@ -102,11 +103,16 @@ func (alloc *Action) Execute(ssn *framework.Session) { return nil, api.NewFitError(task, node, reason) } + predicateStatus, err := ssn.PredicateFn(task, node) + if err != nil { + return nil, fmt.Errorf("allocate predicates failed for task <%s/%s> on node <%s>: %v", + task.Namespace, task.Name, node.Name, err) + } // Only nodes whose status is success after predicate filtering can be scheduled. admitStatus := map[int]struct{}{ api.Success: {}, } - return nil, util.PredicateForAdmitStatus(ssn, task, node, admitStatus) + return nil, util.CheckPredicateStatus(predicateStatus, admitStatus) } // To pick tuple for job, we choose to pick namespace firstly. diff --git a/pkg/scheduler/actions/backfill/backfill.go b/pkg/scheduler/actions/backfill/backfill.go index b0d14d3e6f2..468e011cde8 100644 --- a/pkg/scheduler/actions/backfill/backfill.go +++ b/pkg/scheduler/actions/backfill/backfill.go @@ -77,9 +77,17 @@ func (backfill *Action) Execute(ssn *framework.Session) { admitStatus := map[int]struct{}{ api.Success: {}, } - err := util.PredicateForAdmitStatus(ssn, task, node, admitStatus) + predicateStatus, err := ssn.PredicateFn(task, node) if err != nil { - klog.V(3).Infof("backfill %s", err.Error()) + klog.V(3).Infof("backfill predicates failed for task <%s/%s> on node <%s>: %v", + task.Namespace, task.Name, node.Name, err) + fe.SetNodeError(node.Name, err) + continue + } + err = util.CheckPredicateStatus(predicateStatus, admitStatus) + if err != nil { + klog.V(3).Infof("backfill predicates failed for task <%s/%s> on node <%s>: %v", + task.Namespace, task.Name, node.Name, err) fe.SetNodeError(node.Name, err) continue } diff --git a/pkg/scheduler/actions/preempt/preempt.go b/pkg/scheduler/actions/preempt/preempt.go index 6c9039dac64..c317c903107 100644 --- a/pkg/scheduler/actions/preempt/preempt.go +++ b/pkg/scheduler/actions/preempt/preempt.go @@ -215,7 +215,12 @@ func preempt( api.Success: {}, api.Unschedulable: {}, } - return nil, util.PredicateForAdmitStatus(ssn, task, node, admitStatus) + predicateStatus, err := ssn.PredicateFn(task, node) + if err != nil { + return nil, fmt.Errorf("preempt predicates failed for task <%s/%s> on node <%s>: %v", + task.Namespace, task.Name, node.Name, err) + } + return nil, util.CheckPredicateStatus(predicateStatus, admitStatus) } predicateNodes, _ := predicateHelper.PredicateNodes(preemptor, allNodes, predicateFn, true) diff --git a/pkg/scheduler/actions/reclaim/reclaim.go b/pkg/scheduler/actions/reclaim/reclaim.go index 390598317c3..8a60bbd8e72 100644 --- a/pkg/scheduler/actions/reclaim/reclaim.go +++ b/pkg/scheduler/actions/reclaim/reclaim.go @@ -18,7 +18,6 @@ package reclaim import ( "k8s.io/klog/v2" - "volcano.sh/volcano/pkg/scheduler/api" "volcano.sh/volcano/pkg/scheduler/framework" "volcano.sh/volcano/pkg/scheduler/util" @@ -128,9 +127,16 @@ func (ra *Action) Execute(ssn *framework.Session) { api.Success: {}, api.Unschedulable: {}, } + predicateStatus, err := ssn.PredicateFn(task, n) + if err != nil { + klog.V(3).Infof("reclaim predicates failed for task <%s/%s> on node <%s>: %v", + task.Namespace, task.Name, n.Name, err) + continue + } // If predicates failed, next node. - if err := util.PredicateForAdmitStatus(ssn, task, n, admitStatus); err != nil { - klog.V(3).Infof("reclaim %s", err.Error()) + if err := util.CheckPredicateStatus(predicateStatus, admitStatus); err != nil { + klog.V(3).Infof("reclaim predicates failed for task <%s/%s> on node <%s>: %v", + task.Namespace, task.Name, n.Name, err) continue } diff --git a/pkg/scheduler/util/predicate_helper.go b/pkg/scheduler/util/predicate_helper.go index 56a0e96be27..dfc3de39aac 100644 --- a/pkg/scheduler/util/predicate_helper.go +++ b/pkg/scheduler/util/predicate_helper.go @@ -10,7 +10,6 @@ import ( "k8s.io/klog/v2" "volcano.sh/volcano/pkg/scheduler/api" - "volcano.sh/volcano/pkg/scheduler/framework" ) type PredicateHelper interface { @@ -101,19 +100,14 @@ func (ph *predicateHelper) PredicateNodes(task *api.TaskInfo, nodes []*api.NodeI return predicateNodes, fe } -func PredicateForAdmitStatus(ssn *framework.Session, task *api.TaskInfo, n *api.NodeInfo, admitStatus map[int]struct{}) error { - predicateStatus, err := ssn.PredicateFn(task, n) - if err != nil { - return fmt.Errorf("Predicates failed for task <%s/%s> on node <%s>: %v", - task.Namespace, task.Name, n.Name, err) - } +func CheckPredicateStatus(predicateStatus []*api.Status, admitStatus map[int]struct{}) error { for _, status := range predicateStatus { if status == nil { continue } if _, ok := admitStatus[status.Code]; !ok { - return fmt.Errorf("Predicates failed for task <%s/%s> on node <%s>: %v", - task.Namespace, task.Name, n.Name, status.Reason) + return fmt.Errorf("Predicates status (code: %d) does not meet the expectation (admit status: %v), message: %s", + status.Code, admitStatus, status.Reason) } } return nil