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

@ -383,6 +383,11 @@ func (h *HTTPExtender) IsBinder() bool {
return h.bindVerb != ""
}
// IsPrioritizer returns whether this extender is configured for the Prioritize method.
func (h *HTTPExtender) IsPrioritizer() bool {
return h.prioritizeVerb != ""
}
// Helper function to send messages to the extender
func (h *HTTPExtender) send(action string, args interface{}, result interface{}) error {
out, err := json.Marshal(args)

View File

@ -50,6 +50,9 @@ type Extender interface {
// this pod is managed by this extender.
IsInterested(pod *v1.Pod) bool
// IsPrioritizer returns whether this extender is configured for the Prioritize method.
IsPrioritizer() bool
// ProcessPreemption returns nodes with their victim pods processed by extender based on
// given:
// 1. Pod to schedule

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.

View File

@ -91,6 +91,7 @@ type fakeExtender struct {
interestedPodName string
ignorable bool
gotBind bool
isPrioritizer bool
}
func (f *fakeExtender) Name() string {
@ -140,6 +141,10 @@ func (f *fakeExtender) IsInterested(pod *v1.Pod) bool {
return pod != nil && pod.Name == f.interestedPodName
}
func (f *fakeExtender) IsPrioritizer() bool {
return f.isPrioritizer
}
type falseMapPlugin struct{}
func newFalseMapPlugin() frameworkruntime.PluginFactory {

View File

@ -380,6 +380,11 @@ func (f *FakeExtender) IsBinder() bool {
return true
}
// IsPrioritizer returns true if there are any prioritizers.
func (f *FakeExtender) IsPrioritizer() bool {
return len(f.Prioritizers) > 0
}
// IsInterested returns a bool indicating whether this extender is interested in this Pod.
func (f *FakeExtender) IsInterested(pod *v1.Pod) bool {
return !f.UnInterested