Skip to content

Commit

Permalink
Prioritize scheduling to machines that are satisfied with current res…
Browse files Browse the repository at this point in the history
…ources, and then consider machines that are satisfied with future resources

Signed-off-by: wangyang <wangyang8126@gmail.com>
  • Loading branch information
wangyang0616 committed May 24, 2023
1 parent 86ff941 commit 2dcbdd8
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions pkg/scheduler/actions/allocate/allocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 2dcbdd8

Please sign in to comment.