@@ -54,6 +54,11 @@ const (
54
54
// certain minimum of nodes are checked for feasibility. This in turn helps
55
55
// ensure a minimum level of spreading.
56
56
minFeasibleNodesToFind = 100
57
+ // minFeasibleNodesPercentageToFind is the minimum percentage of nodes that
58
+ // would be scored in each scheduling cycle. This is a semi-arbitrary value
59
+ // to ensure that a certain minimum of nodes are checked for feasibility.
60
+ // This in turn helps ensure a minimum level of spreading.
61
+ minFeasibleNodesPercentageToFind = 5
57
62
)
58
63
59
64
// FailedPredicateMap declares a map[string][]algorithm.PredicateFailureReason type.
@@ -375,15 +380,24 @@ func (g *genericScheduler) getLowerPriorityNominatedPods(pod *v1.Pod, nodeName s
375
380
376
381
// numFeasibleNodesToFind returns the number of feasible nodes that once found, the scheduler stops
377
382
// its search for more feasible nodes.
378
- func (g * genericScheduler ) numFeasibleNodesToFind (numAllNodes int32 ) int32 {
379
- if numAllNodes < minFeasibleNodesToFind || g .percentageOfNodesToScore <= 0 ||
380
- g .percentageOfNodesToScore >= 100 {
383
+ func (g * genericScheduler ) numFeasibleNodesToFind (numAllNodes int32 ) (numNodes int32 ) {
384
+ if numAllNodes < minFeasibleNodesToFind || g .percentageOfNodesToScore >= 100 {
381
385
return numAllNodes
382
386
}
383
- numNodes := numAllNodes * g .percentageOfNodesToScore / 100
387
+
388
+ adaptivePercentage := g .percentageOfNodesToScore
389
+ if adaptivePercentage <= 0 {
390
+ adaptivePercentage = schedulerapi .DefaultPercentageOfNodesToScore - numAllNodes / 125
391
+ if adaptivePercentage < minFeasibleNodesPercentageToFind {
392
+ adaptivePercentage = minFeasibleNodesPercentageToFind
393
+ }
394
+ }
395
+
396
+ numNodes = numAllNodes * adaptivePercentage / 100
384
397
if numNodes < minFeasibleNodesToFind {
385
398
return minFeasibleNodesToFind
386
399
}
400
+
387
401
return numNodes
388
402
}
389
403
0 commit comments