diff --git a/pkg/scheduler/actions/allocate/allocate.go b/pkg/scheduler/actions/allocate/allocate.go index 02fd5664265..7636446ba1d 100644 --- a/pkg/scheduler/actions/allocate/allocate.go +++ b/pkg/scheduler/actions/allocate/allocate.go @@ -183,25 +183,46 @@ func (alloc *Action) Execute(ssn *framework.Session) { break } - var candidateNodes []*api.NodeInfo + var gradeCandidateNodes [][]*api.NodeInfo + var idleCandidateNodes []*api.NodeInfo + var futureIdleCandidateNodes []*api.NodeInfo for _, n := range predicateNodes { - if task.InitResreq.LessEqual(n.Idle, api.Zero) || task.InitResreq.LessEqual(n.FutureIdle(), api.Zero) { - candidateNodes = append(candidateNodes, n) + if task.InitResreq.LessEqual(n.Idle, api.Zero) { + idleCandidateNodes = append(idleCandidateNodes, n) + } else if task.InitResreq.LessEqual(n.FutureIdle(), api.Zero) { + futureIdleCandidateNodes = append(futureIdleCandidateNodes, n) + } else { + klog.V(5).Infof("Predicate filtered node %v, idle: %v and future idle: %v do not meet the requirements of task: %v", + n.Name, n.Idle, n.FutureIdle(), task.Name) } } + gradeCandidateNodes = append(gradeCandidateNodes, idleCandidateNodes) + gradeCandidateNodes = append(gradeCandidateNodes, futureIdleCandidateNodes) var node *api.NodeInfo - switch { - case len(candidateNodes) == 0: // If not candidate nodes for this task, skip it. - continue - case len(candidateNodes) == 1: // If only one node after predicate, just use it. - node = candidateNodes[0] - case len(candidateNodes) > 1: // If more than one node after predicate, using "the best" one - nodeScores := util.PrioritizeNodes(task, candidateNodes, ssn.BatchNodeOrderFn, ssn.NodeOrderMapFn, ssn.NodeOrderReduceFn) - - node = ssn.BestNodeFn(task, nodeScores) - if node == nil { - node = util.SelectBestNode(nodeScores) + for index, candidateNodes := range gradeCandidateNodes { + switch { + case len(candidateNodes) == 0: // If not candidate nodes for this task, skip it. + klog.V(3).Infof("Task: %v, no matching node is found in the candidateNodes list."+ + "gradeCandidateNodes index is %d ", task.Name, index) + case len(candidateNodes) == 1: // If only one node after predicate, just use it. + node = candidateNodes[0] + case len(candidateNodes) > 1: // If more than one node after predicate, using "the best" one + nodeScores := util.PrioritizeNodes(task, candidateNodes, ssn.BatchNodeOrderFn, ssn.NodeOrderMapFn, ssn.NodeOrderReduceFn) + + node = ssn.BestNodeFn(task, nodeScores) + if node == nil { + node = util.SelectBestNode(nodeScores) + } + } + + if node != nil && index == 0 { + klog.V(5).Infof("The node: %v in the idle machine list meets the task: %v requirements, and the future idle machines are not scored", + node.Name, task.Name) + for _, node := range futureIdleCandidateNodes { + klog.V(5).Infof("future idle node %v, idle: %v", node.Name, node.Idle) + } + break } }