scheduler

package
v0.12.1-0...-0a124f2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2017 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultExtenderTimeout = 5 * time.Second
)
View Source
const NoNodeAvailableMsg = "No nodes are available that match all of the following predicates:"

Variables

View Source
var ErrNoNodesAvailable = fmt.Errorf("no nodes available to schedule pods")

Functions

func EqualPriorityMap

func EqualPriorityMap(_ *v1.Pod, _ interface{}, nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)

EqualPriority is a prioritizer function that gives an equal weight of one to all nodes

func NewGenericScheduler

func NewGenericScheduler(
	cache schedulercache.Cache,
	predicates map[string]algorithm.FitPredicate,
	predicateMetaProducer algorithm.MetadataProducer,
	prioritizers []algorithm.PriorityConfig,
	priorityMetaProducer algorithm.MetadataProducer,
	extenders []algorithm.SchedulerExtender) algorithm.ScheduleAlgorithm

func NewHTTPExtender

func NewHTTPExtender(config *schedulerapi.ExtenderConfig, apiVersion string) (algorithm.SchedulerExtender, error)

func PrioritizeNodes

func PrioritizeNodes(
	pod *v1.Pod,
	nodeNameToInfo map[string]*schedulercache.NodeInfo,
	meta interface{},
	priorityConfigs []algorithm.PriorityConfig,
	nodes []*v1.Node,
	extenders []algorithm.SchedulerExtender,
) (schedulerapi.HostPriorityList, error)

Prioritizes the nodes by running the individual priority functions in parallel. Each priority function is expected to set a score of 0-10 0 is the lowest priority score (least preferred node) and 10 is the highest Each priority function can also have its own weight The node scores returned by the priority function are multiplied by the weights to get weighted scores All scores are finally combined (added) to get the total weighted scores of all nodes

Types

type AlgorithmCache

type AlgorithmCache struct {
	// contains filtered or unexported fields
}

type Binder

type Binder interface {
	Bind(binding *v1.Binding) error
}

Binder knows how to write a binding.

type Config

type Config struct {
	// It is expected that changes made via SchedulerCache will be observed
	// by NodeLister and Algorithm.
	SchedulerCache schedulercache.Cache
	NodeLister     algorithm.NodeLister
	Algorithm      algorithm.ScheduleAlgorithm
	Binder         Binder
	// PodConditionUpdater is used only in case of scheduling errors. If we succeed
	// with scheduling, PodScheduled condition will be updated in apiserver in /bind
	// handler so that binding and setting PodCondition it is atomic.
	PodConditionUpdater PodConditionUpdater

	// NextPod should be a function that blocks until the next pod
	// is available. We don't use a channel for this, because scheduling
	// a pod may take some amount of time and we don't want pods to get
	// stale while they sit in a channel.
	NextPod func() *v1.Pod

	// Error is called if there is an error. It is passed the pod in
	// question, and the error
	Error func(*v1.Pod, error)

	// Recorder is the EventRecorder to use
	Recorder record.EventRecorder

	// Close this to shut down the scheduler.
	StopEverything chan struct{}
}

TODO over time we should make this struct a hidden implementation detail of the scheduler.

type Configurator

type Configurator interface {
	GetPriorityFunctionConfigs(priorityKeys sets.String) ([]algorithm.PriorityConfig, error)
	GetPriorityMetadataProducer() (algorithm.MetadataProducer, error)
	GetPredicateMetadataProducer() (algorithm.MetadataProducer, error)
	GetPredicates(predicateKeys sets.String) (map[string]algorithm.FitPredicate, error)
	GetHardPodAffinitySymmetricWeight() int
	GetFailureDomains() []string
	GetSchedulerName() string
	MakeDefaultErrorFunc(backoff *util.PodBackoff, podQueue *cache.FIFO) func(pod *v1.Pod, err error)

	// Probably doesn't need to be public.  But exposed for now in case.
	ResponsibleForPod(pod *v1.Pod) bool

	// Needs to be exposed for things like integration tests where we want to make fake nodes.
	GetNodeStore() cache.Store
	GetClient() clientset.Interface
	GetScheduledPodListerIndexer() cache.Indexer
	Run()

	Create() (*Config, error)
	CreateFromProvider(providerName string) (*Config, error)
	CreateFromConfig(policy schedulerapi.Policy) (*Config, error)
	CreateFromKeys(predicateKeys, priorityKeys sets.String, extenders []algorithm.SchedulerExtender) (*Config, error)
}

These are the functions which need to be provided in order to build a Scheduler configuration. An implementation of this can be seen in factory.go.

type EquivalenceCache

type EquivalenceCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Store a map of predicate cache with maxsize

func NewEquivalenceCache

func NewEquivalenceCache(getEquivalencePodFunc algorithm.GetEquivalencePodFunc) *EquivalenceCache

func (*EquivalenceCache) AddPodPredicatesCache

func (ec *EquivalenceCache) AddPodPredicatesCache(pod *v1.Pod, fitNodeList []*v1.Node, failedPredicates *FailedPredicateMap)

AddPodPredicatesCache cache pod predicate for equivalence class

func (*EquivalenceCache) GetCachedPredicates

func (ec *EquivalenceCache) GetCachedPredicates(pod *v1.Pod, nodes []*v1.Node) ([]*v1.Node, FailedPredicateMap, []*v1.Node)

GetCachedPredicates gets cached predicates for equivalence class

func (*EquivalenceCache) SendClearAllCacheReq

func (ec *EquivalenceCache) SendClearAllCacheReq()

SendClearAllCacheReq marks all cached item as invalid

func (*EquivalenceCache) SendInvalidAlgorithmCacheReq

func (ec *EquivalenceCache) SendInvalidAlgorithmCacheReq(nodeName string)

SendInvalidAlgorithmCacheReq marks AlgorithmCache item as invalid

type FailedPredicateMap

type FailedPredicateMap map[string][]algorithm.PredicateFailureReason

type FitError

type FitError struct {
	Pod              *v1.Pod
	FailedPredicates FailedPredicateMap
}

func (*FitError) Error

func (f *FitError) Error() string

Error returns detailed information of why the pod failed to fit on each node

type HTTPExtender

type HTTPExtender struct {
	// contains filtered or unexported fields
}

HTTPExtender implements the algorithm.SchedulerExtender interface.

func (*HTTPExtender) Filter

func (h *HTTPExtender) Filter(pod *v1.Pod, nodes []*v1.Node) ([]*v1.Node, schedulerapi.FailedNodesMap, error)

Filter based on extender implemented predicate functions. The filtered list is expected to be a subset of the supplied list. failedNodesMap optionally contains the list of failed nodes and failure reasons.

func (*HTTPExtender) Prioritize

func (h *HTTPExtender) Prioritize(pod *v1.Pod, nodes []*v1.Node) (*schedulerapi.HostPriorityList, int, error)

Prioritize based on extender implemented priority functions. Weight*priority is added up for each such priority function. The returned score is added to the score computed by Kubernetes scheduler. The total score is used to do the host selection.

type HostPredicate

type HostPredicate struct {
	Fit         bool
	FailReasons []algorithm.PredicateFailureReason
}

type PodConditionUpdater

type PodConditionUpdater interface {
	Update(pod *v1.Pod, podCondition *v1.PodCondition) error
}

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler watches for new unscheduled pods. It attempts to find nodes that they fit on and writes bindings back to the api server.

func New

func New(c *Config) *Scheduler

New returns a new scheduler. TODO replace this with NewFromConfigurator.

func NewFromConfigurator

func NewFromConfigurator(c Configurator, modifiers ...func(c *Config)) (*Scheduler, error)

NewFromConfigurator returns a new scheduler that is created entirely by the Configurator. Assumes Create() is implemented. Supports intermediate Config mutation for now if you provide modifier functions which will run after Config is created.

func (*Scheduler) Run

func (s *Scheduler) Run()

Run begins watching and scheduling. It starts a goroutine and returns immediately.

func (*Scheduler) StopEverything

func (sched *Scheduler) StopEverything()

Directories

Path Synopsis
Package scheduler contains a generic Scheduler interface and several implementations.
Package scheduler contains a generic Scheduler interface and several implementations.
This package is used to register algorithm provider plugins.
This package is used to register algorithm provider plugins.
defaults
This is the default algorithm provider for the scheduler.
This is the default algorithm provider for the scheduler.
api
v1
Package factory can set up a scheduler.
Package factory can set up a scheduler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL