Don't evaluate extra nodes if there's no score plugin defined
This commit is contained in:
		@@ -383,6 +383,11 @@ func (h *HTTPExtender) IsBinder() bool {
 | 
				
			|||||||
	return h.bindVerb != ""
 | 
						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
 | 
					// Helper function to send messages to the extender
 | 
				
			||||||
func (h *HTTPExtender) send(action string, args interface{}, result interface{}) error {
 | 
					func (h *HTTPExtender) send(action string, args interface{}, result interface{}) error {
 | 
				
			||||||
	out, err := json.Marshal(args)
 | 
						out, err := json.Marshal(args)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,6 +50,9 @@ type Extender interface {
 | 
				
			|||||||
	// this pod is managed by this extender.
 | 
						// this pod is managed by this extender.
 | 
				
			||||||
	IsInterested(pod *v1.Pod) bool
 | 
						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
 | 
						// ProcessPreemption returns nodes with their victim pods processed by extender based on
 | 
				
			||||||
	// given:
 | 
						// given:
 | 
				
			||||||
	//   1. Pod to schedule
 | 
						//   1. Pod to schedule
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -544,6 +544,19 @@ func (sched *Scheduler) evaluateNominatedNode(ctx context.Context, pod *v1.Pod,
 | 
				
			|||||||
	return feasibleNodes, nil
 | 
						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.
 | 
					// findNodesThatPassFilters finds the nodes that fit the filter plugins.
 | 
				
			||||||
func (sched *Scheduler) findNodesThatPassFilters(
 | 
					func (sched *Scheduler) findNodesThatPassFilters(
 | 
				
			||||||
	ctx context.Context,
 | 
						ctx context.Context,
 | 
				
			||||||
@@ -554,6 +567,9 @@ func (sched *Scheduler) findNodesThatPassFilters(
 | 
				
			|||||||
	nodes []*framework.NodeInfo) ([]*framework.NodeInfo, error) {
 | 
						nodes []*framework.NodeInfo) ([]*framework.NodeInfo, error) {
 | 
				
			||||||
	numAllNodes := len(nodes)
 | 
						numAllNodes := len(nodes)
 | 
				
			||||||
	numNodesToFind := sched.numFeasibleNodesToFind(fwk.PercentageOfNodesToScore(), int32(numAllNodes))
 | 
						numNodesToFind := sched.numFeasibleNodesToFind(fwk.PercentageOfNodesToScore(), int32(numAllNodes))
 | 
				
			||||||
 | 
						if !sched.hasScoring(fwk) {
 | 
				
			||||||
 | 
							numNodesToFind = 1
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 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.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,6 +91,7 @@ type fakeExtender struct {
 | 
				
			|||||||
	interestedPodName string
 | 
						interestedPodName string
 | 
				
			||||||
	ignorable         bool
 | 
						ignorable         bool
 | 
				
			||||||
	gotBind           bool
 | 
						gotBind           bool
 | 
				
			||||||
 | 
						isPrioritizer     bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (f *fakeExtender) Name() string {
 | 
					func (f *fakeExtender) Name() string {
 | 
				
			||||||
@@ -140,6 +141,10 @@ func (f *fakeExtender) IsInterested(pod *v1.Pod) bool {
 | 
				
			|||||||
	return pod != nil && pod.Name == f.interestedPodName
 | 
						return pod != nil && pod.Name == f.interestedPodName
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (f *fakeExtender) IsPrioritizer() bool {
 | 
				
			||||||
 | 
						return f.isPrioritizer
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type falseMapPlugin struct{}
 | 
					type falseMapPlugin struct{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newFalseMapPlugin() frameworkruntime.PluginFactory {
 | 
					func newFalseMapPlugin() frameworkruntime.PluginFactory {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -380,6 +380,11 @@ func (f *FakeExtender) IsBinder() bool {
 | 
				
			|||||||
	return true
 | 
						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.
 | 
					// IsInterested returns a bool indicating whether this extender is interested in this Pod.
 | 
				
			||||||
func (f *FakeExtender) IsInterested(pod *v1.Pod) bool {
 | 
					func (f *FakeExtender) IsInterested(pod *v1.Pod) bool {
 | 
				
			||||||
	return !f.UnInterested
 | 
						return !f.UnInterested
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user