mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #84232 from ahg-g/ahg-tree2
fixed node search starting point
This commit is contained in:
commit
a90b9402c9
@ -160,6 +160,7 @@ type genericScheduler struct {
|
|||||||
disablePreemption bool
|
disablePreemption bool
|
||||||
percentageOfNodesToScore int32
|
percentageOfNodesToScore int32
|
||||||
enableNonPreempting bool
|
enableNonPreempting bool
|
||||||
|
lastProcessedNodeIndex int
|
||||||
}
|
}
|
||||||
|
|
||||||
// snapshot snapshots scheduler cache and node infos for all fit and priority
|
// snapshot snapshots scheduler cache and node infos for all fit and priority
|
||||||
@ -460,8 +461,8 @@ func (g *genericScheduler) findNodesThatFit(ctx context.Context, state *framewor
|
|||||||
if len(g.predicates) == 0 && !g.framework.HasFilterPlugins() {
|
if len(g.predicates) == 0 && !g.framework.HasFilterPlugins() {
|
||||||
filtered = g.nodeInfoSnapshot.ListNodes()
|
filtered = g.nodeInfoSnapshot.ListNodes()
|
||||||
} else {
|
} else {
|
||||||
allNodes := int32(len(g.nodeInfoSnapshot.NodeInfoList))
|
allNodes := len(g.nodeInfoSnapshot.NodeInfoList)
|
||||||
numNodesToFind := g.numFeasibleNodesToFind(allNodes)
|
numNodesToFind := g.numFeasibleNodesToFind(int32(allNodes))
|
||||||
|
|
||||||
// Create filtered list with enough space to avoid growing it
|
// Create filtered list with enough space to avoid growing it
|
||||||
// and allow assigning.
|
// and allow assigning.
|
||||||
@ -479,7 +480,9 @@ func (g *genericScheduler) findNodesThatFit(ctx context.Context, state *framewor
|
|||||||
state.Write(migration.PredicatesStateKey, &migration.PredicatesStateData{Reference: meta})
|
state.Write(migration.PredicatesStateKey, &migration.PredicatesStateData{Reference: meta})
|
||||||
|
|
||||||
checkNode := func(i int) {
|
checkNode := func(i int) {
|
||||||
nodeInfo := g.nodeInfoSnapshot.NodeInfoList[i]
|
// 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.
|
||||||
|
nodeInfo := g.nodeInfoSnapshot.NodeInfoList[(g.lastProcessedNodeIndex+i)%allNodes]
|
||||||
fits, failedPredicates, status, err := g.podFitsOnNode(
|
fits, failedPredicates, status, err := g.podFitsOnNode(
|
||||||
ctx,
|
ctx,
|
||||||
state,
|
state,
|
||||||
@ -514,7 +517,9 @@ func (g *genericScheduler) findNodesThatFit(ctx context.Context, state *framewor
|
|||||||
|
|
||||||
// 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.
|
||||||
workqueue.ParallelizeUntil(ctx, 16, int(allNodes), checkNode)
|
workqueue.ParallelizeUntil(ctx, 16, allNodes, checkNode)
|
||||||
|
processedNodes := int(filteredLen) + len(filteredNodesStatuses) + len(failedPredicateMap)
|
||||||
|
g.lastProcessedNodeIndex = (g.lastProcessedNodeIndex + processedNodes) % allNodes
|
||||||
|
|
||||||
filtered = filtered[:filteredLen]
|
filtered = filtered[:filteredLen]
|
||||||
if err := errCh.ReceiveError(); err != nil {
|
if err := errCh.ReceiveError(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user