diff --git a/pkg/scheduler/algorithm/scheduler_interface.go b/pkg/scheduler/algorithm/scheduler_interface.go index bdb34e4e76..81dedd4292 100644 --- a/pkg/scheduler/algorithm/scheduler_interface.go +++ b/pkg/scheduler/algorithm/scheduler_interface.go @@ -72,20 +72,3 @@ type SchedulerExtender interface { // is unavailable. This gives scheduler ability to fail fast and tolerate non-critical extenders as well. IsIgnorable() bool } - -// ScheduleAlgorithm is an interface implemented by things that know how to schedule pods -// onto machines. -type ScheduleAlgorithm interface { - Schedule(*v1.Pod, NodeLister) (selectedMachine string, err error) - // Preempt receives scheduling errors for a pod and tries to create room for - // the pod by preempting lower priority pods if possible. - // It returns the node where preemption happened, a list of preempted pods, a - // list of pods whose nominated node name should be removed, and error if any. - Preempt(*v1.Pod, NodeLister, error) (selectedNode *v1.Node, preemptedPods []*v1.Pod, cleanupNominatedPods []*v1.Pod, err error) - // Predicates() returns a pointer to a map of predicate functions. This is - // exposed for testing. - Predicates() map[string]FitPredicate - // Prioritizers returns a slice of priority config. This is exposed for - // testing. - Prioritizers() []PriorityConfig -} diff --git a/pkg/scheduler/core/generic_scheduler.go b/pkg/scheduler/core/generic_scheduler.go index 2ac49fe4d7..f2cb1a82c5 100644 --- a/pkg/scheduler/core/generic_scheduler.go +++ b/pkg/scheduler/core/generic_scheduler.go @@ -96,6 +96,24 @@ func (f *FitError) Error() string { return reasonMsg } +// ScheduleAlgorithm is an interface implemented by things that know how to schedule pods +// onto machines. +// TODO: Rename this type. +type ScheduleAlgorithm interface { + Schedule(*v1.Pod, algorithm.NodeLister) (selectedMachine string, err error) + // Preempt receives scheduling errors for a pod and tries to create room for + // the pod by preempting lower priority pods if possible. + // It returns the node where preemption happened, a list of preempted pods, a + // list of pods whose nominated node name should be removed, and error if any. + Preempt(*v1.Pod, algorithm.NodeLister, error) (selectedNode *v1.Node, preemptedPods []*v1.Pod, cleanupNominatedPods []*v1.Pod, err error) + // Predicates() returns a pointer to a map of predicate functions. This is + // exposed for testing. + Predicates() map[string]algorithm.FitPredicate + // Prioritizers returns a slice of priority config. This is exposed for + // testing. + Prioritizers() []algorithm.PriorityConfig +} + type genericScheduler struct { cache schedulerinternalcache.Cache equivalenceCache *equivalence.Cache @@ -1164,7 +1182,7 @@ func NewGenericScheduler( alwaysCheckAllPredicates bool, disablePreemption bool, percentageOfNodesToScore int32, -) algorithm.ScheduleAlgorithm { +) ScheduleAlgorithm { return &genericScheduler{ cache: cache, equivalenceCache: eCache, diff --git a/pkg/scheduler/factory/factory.go b/pkg/scheduler/factory/factory.go index 73fa15858a..0338a74ce7 100644 --- a/pkg/scheduler/factory/factory.go +++ b/pkg/scheduler/factory/factory.go @@ -103,7 +103,7 @@ type Config struct { // successfully binding a pod Ecache *equivalence.Cache NodeLister algorithm.NodeLister - Algorithm algorithm.ScheduleAlgorithm + Algorithm core.ScheduleAlgorithm GetBinder func(pod *v1.Pod) Binder // PodConditionUpdater is used only in case of scheduling errors. If we succeed // with scheduling, PodScheduled condition will be updated in apiserver in /bind diff --git a/pkg/scheduler/scheduler_test.go b/pkg/scheduler/scheduler_test.go index 935801babc..51bae5d7ed 100644 --- a/pkg/scheduler/scheduler_test.go +++ b/pkg/scheduler/scheduler_test.go @@ -211,7 +211,7 @@ func TestScheduler(t *testing.T) { name string injectBindError error sendPod *v1.Pod - algo algorithm.ScheduleAlgorithm + algo core.ScheduleAlgorithm expectErrorPod *v1.Pod expectForgetPod *v1.Pod expectAssumedPod *v1.Pod