mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
scheduler: do not update sched.nextStartNodeIndex when evaluate nominated node
This commit is contained in:
parent
89aaf7c02d
commit
d3092cd296
@ -414,6 +414,10 @@ func (sched *Scheduler) findNodesThatFitPod(ctx context.Context, fwk framework.F
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
feasibleNodes, err := sched.findNodesThatPassFilters(ctx, fwk, state, pod, diagnosis, nodes)
|
feasibleNodes, err := sched.findNodesThatPassFilters(ctx, fwk, state, pod, diagnosis, nodes)
|
||||||
|
// always try to update the sched.nextStartNodeIndex regardless of whether an error has occurred
|
||||||
|
// this is helpful to make sure that all the nodes have a chance to be searched
|
||||||
|
processedNodes := len(feasibleNodes) + len(diagnosis.NodeToStatusMap)
|
||||||
|
sched.nextStartNodeIndex = (sched.nextStartNodeIndex + processedNodes) % len(nodes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, diagnosis, err
|
return nil, diagnosis, err
|
||||||
}
|
}
|
||||||
@ -453,18 +457,17 @@ func (sched *Scheduler) findNodesThatPassFilters(
|
|||||||
pod *v1.Pod,
|
pod *v1.Pod,
|
||||||
diagnosis framework.Diagnosis,
|
diagnosis framework.Diagnosis,
|
||||||
nodes []*framework.NodeInfo) ([]*v1.Node, error) {
|
nodes []*framework.NodeInfo) ([]*v1.Node, error) {
|
||||||
numNodesToFind := sched.numFeasibleNodesToFind(int32(len(nodes)))
|
numAllNodes := len(nodes)
|
||||||
|
numNodesToFind := sched.numFeasibleNodesToFind(int32(numAllNodes))
|
||||||
|
|
||||||
// Create feasible list with enough space to avoid growing it
|
// Create feasible list with enough space to avoid growing it
|
||||||
// and allow assigning.
|
// and allow assigning.
|
||||||
feasibleNodes := make([]*v1.Node, numNodesToFind)
|
feasibleNodes := make([]*v1.Node, numNodesToFind)
|
||||||
|
|
||||||
if !fwk.HasFilterPlugins() {
|
if !fwk.HasFilterPlugins() {
|
||||||
length := len(nodes)
|
|
||||||
for i := range feasibleNodes {
|
for i := range feasibleNodes {
|
||||||
feasibleNodes[i] = nodes[(sched.nextStartNodeIndex+i)%length].Node()
|
feasibleNodes[i] = nodes[(sched.nextStartNodeIndex+i)%numAllNodes].Node()
|
||||||
}
|
}
|
||||||
sched.nextStartNodeIndex = (sched.nextStartNodeIndex + len(feasibleNodes)) % length
|
|
||||||
return feasibleNodes, nil
|
return feasibleNodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,7 +478,7 @@ func (sched *Scheduler) findNodesThatPassFilters(
|
|||||||
checkNode := func(i int) {
|
checkNode := func(i int) {
|
||||||
// We check the nodes starting from where we left off in the previous scheduling cycle,
|
// We check the nodes starting from where we left off in the previous scheduling cycle,
|
||||||
// this is to make sure all nodes have the same chance of being examined across pods.
|
// this is to make sure all nodes have the same chance of being examined across pods.
|
||||||
nodeInfo := nodes[(sched.nextStartNodeIndex+i)%len(nodes)]
|
nodeInfo := nodes[(sched.nextStartNodeIndex+i)%numAllNodes]
|
||||||
status := fwk.RunFilterPluginsWithNominatedPods(ctx, state, pod, nodeInfo)
|
status := fwk.RunFilterPluginsWithNominatedPods(ctx, state, pod, nodeInfo)
|
||||||
if status.Code() == framework.Error {
|
if status.Code() == framework.Error {
|
||||||
errCh.SendErrorWithCancel(status.AsError(), cancel)
|
errCh.SendErrorWithCancel(status.AsError(), cancel)
|
||||||
@ -508,14 +511,11 @@ func (sched *Scheduler) findNodesThatPassFilters(
|
|||||||
|
|
||||||
// Stops searching for more nodes once the configured number of feasible nodes
|
// Stops searching for more nodes once the configured number of feasible nodes
|
||||||
// are found.
|
// are found.
|
||||||
fwk.Parallelizer().Until(ctx, len(nodes), checkNode)
|
fwk.Parallelizer().Until(ctx, numAllNodes, checkNode)
|
||||||
processedNodes := int(feasibleNodesLen) + len(diagnosis.NodeToStatusMap)
|
|
||||||
sched.nextStartNodeIndex = (sched.nextStartNodeIndex + processedNodes) % len(nodes)
|
|
||||||
|
|
||||||
feasibleNodes = feasibleNodes[:feasibleNodesLen]
|
feasibleNodes = feasibleNodes[:feasibleNodesLen]
|
||||||
if err := errCh.ReceiveError(); err != nil {
|
if err := errCh.ReceiveError(); err != nil {
|
||||||
statusCode = framework.Error
|
statusCode = framework.Error
|
||||||
return nil, err
|
return feasibleNodes, err
|
||||||
}
|
}
|
||||||
return feasibleNodes, nil
|
return feasibleNodes, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user