Don't evaluate extra nodes if there's no score plugin defined

This commit is contained in:
Aleksandra Malinowska
2023-11-27 09:50:57 +01:00
parent 0cabb55f7c
commit e19be41f58
5 changed files with 34 additions and 0 deletions

View File

@@ -544,6 +544,19 @@ func (sched *Scheduler) evaluateNominatedNode(ctx context.Context, pod *v1.Pod,
return feasibleNodes, nil
}
// hasScoring checks if scoring nodes is configured.
func (sched *Scheduler) hasScoring(fwk framework.Framework) bool {
if fwk.HasScorePlugins() {
return true
}
for _, extender := range sched.Extenders {
if extender.IsPrioritizer() {
return true
}
}
return false
}
// findNodesThatPassFilters finds the nodes that fit the filter plugins.
func (sched *Scheduler) findNodesThatPassFilters(
ctx context.Context,
@@ -554,6 +567,9 @@ func (sched *Scheduler) findNodesThatPassFilters(
nodes []*framework.NodeInfo) ([]*framework.NodeInfo, error) {
numAllNodes := len(nodes)
numNodesToFind := sched.numFeasibleNodesToFind(fwk.PercentageOfNodesToScore(), int32(numAllNodes))
if !sched.hasScoring(fwk) {
numNodesToFind = 1
}
// Create feasible list with enough space to avoid growing it
// and allow assigning.