mirror of https://github.com/k3s-io/k3s
Move `ScheduleAlgorithm` to the core package.
This moves the type `ScheduleAlgorithm` from `pkg/scheduler/algorithm` to `pkg/scheduler/core`. The reason for this move is to fix our import dependency graph and allow predicate & priority types to be moved into their appropriate packages. The new location makes sense because `core` is the only package that exports an implementation of this type.pull/564/head
parent
59fce36866
commit
8e25361320
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue