mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Don't evaluate extra nodes if there's no score plugin defined
This commit is contained in:
parent
0cabb55f7c
commit
e19be41f58
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user