Documentation ¶
Index ¶
- Constants
- Variables
- func EqualPriorityMap(_ *v1.Pod, _ interface{}, nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)
- func NewGenericScheduler(cache schedulercache.Cache, eCache *EquivalenceCache, podQueue SchedulingQueue, ...) algorithm.ScheduleAlgorithm
- func NewHTTPExtender(config *schedulerapi.ExtenderConfig) (algorithm.SchedulerExtender, error)
- func NominatedNodeName(pod *v1.Pod) string
- func PrioritizeNodes(pod *v1.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo, ...) (schedulerapi.HostPriorityList, error)
- type AlgorithmCache
- type EquivalenceCache
- func (ec *EquivalenceCache) InvalidateAllCachedPredicateItemOfNode(nodeName string)
- func (ec *EquivalenceCache) InvalidateCachedPredicateItem(nodeName string, predicateKeys sets.String)
- func (ec *EquivalenceCache) InvalidateCachedPredicateItemForPodAdd(pod *v1.Pod, nodeName string)
- func (ec *EquivalenceCache) InvalidateCachedPredicateItemOfAllNodes(predicateKeys sets.String)
- func (ec *EquivalenceCache) PredicateWithECache(podName, nodeName, predicateKey string, equivalenceHash uint64) (bool, []algorithm.PredicateFailureReason, bool)
- func (ec *EquivalenceCache) UpdateCachedPredicateItem(podName, nodeName, predicateKey string, fit bool, ...)
- type FIFO
- func (f *FIFO) Add(pod *v1.Pod) error
- func (f *FIFO) AddIfNotPresent(pod *v1.Pod) error
- func (f *FIFO) AddUnschedulableIfNotPresent(pod *v1.Pod) error
- func (f *FIFO) AssignedPodAdded(pod *v1.Pod)
- func (f *FIFO) AssignedPodUpdated(pod *v1.Pod)
- func (f *FIFO) Delete(pod *v1.Pod) error
- func (f *FIFO) MoveAllToActiveQueue()
- func (f *FIFO) Pop() (*v1.Pod, error)
- func (f *FIFO) Update(pod *v1.Pod) error
- func (f *FIFO) WaitingPodsForNode(nodeName string) []*v1.Pod
- type FailedPredicateMap
- type FitError
- type HTTPExtender
- func (h *HTTPExtender) Bind(binding *v1.Binding) error
- func (h *HTTPExtender) Filter(pod *v1.Pod, nodes []*v1.Node, ...) ([]*v1.Node, schedulerapi.FailedNodesMap, error)
- func (h *HTTPExtender) IsBinder() bool
- func (h *HTTPExtender) Prioritize(pod *v1.Pod, nodes []*v1.Node) (*schedulerapi.HostPriorityList, int, error)
- type Heap
- func (h *Heap) Add(obj interface{}) error
- func (h *Heap) AddIfNotPresent(obj interface{}) error
- func (h *Heap) BulkAdd(list []interface{}) error
- func (h *Heap) Delete(obj interface{}) error
- func (h *Heap) Get(obj interface{}) (interface{}, bool, error)
- func (h *Heap) GetByKey(key string) (interface{}, bool, error)
- func (h *Heap) List() []interface{}
- func (h *Heap) Pop() (interface{}, error)
- func (h *Heap) Update(obj interface{}) error
- type HostPredicate
- type KeyFunc
- type LessFunc
- type PredicateMap
- type PriorityQueue
- func (p *PriorityQueue) Add(pod *v1.Pod) error
- func (p *PriorityQueue) AddIfNotPresent(pod *v1.Pod) error
- func (p *PriorityQueue) AddUnschedulableIfNotPresent(pod *v1.Pod) error
- func (p *PriorityQueue) AssignedPodAdded(pod *v1.Pod)
- func (p *PriorityQueue) AssignedPodUpdated(pod *v1.Pod)
- func (p *PriorityQueue) Delete(pod *v1.Pod) error
- func (p *PriorityQueue) MoveAllToActiveQueue()
- func (p *PriorityQueue) Pop() (*v1.Pod, error)
- func (p *PriorityQueue) Update(pod *v1.Pod) error
- func (p *PriorityQueue) WaitingPodsForNode(nodeName string) []*v1.Pod
- type SchedulingQueue
- type UnschedulablePods
- type UnschedulablePodsMap
- func (u *UnschedulablePodsMap) Add(pod *v1.Pod)
- func (u *UnschedulablePodsMap) Clear()
- func (u *UnschedulablePodsMap) Delete(pod *v1.Pod)
- func (u *UnschedulablePodsMap) Get(pod *v1.Pod) *v1.Pod
- func (u *UnschedulablePodsMap) GetPodsWaitingForNode(nodeName string) []*v1.Pod
- func (u *UnschedulablePodsMap) Update(pod *v1.Pod)
- type Victims
Constants ¶
const ( NoNodeAvailableMsg = "0/%v nodes are available" // NominatedNodeAnnotationKey is used to annotate a pod that has preempted other pods. // The scheduler uses the annotation to find that the pod shouldn't preempt more pods // when it gets to the head of scheduling queue again. // See podEligibleToPreemptOthers() for more information. NominatedNodeAnnotationKey = "NominatedNodeName" )
const (
DefaultExtenderTimeout = 5 * time.Second
)
Variables ¶
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, eCache *EquivalenceCache, podQueue SchedulingQueue, predicates map[string]algorithm.FitPredicate, predicateMetaProducer algorithm.PredicateMetadataProducer, prioritizers []algorithm.PriorityConfig, priorityMetaProducer algorithm.MetadataProducer, extenders []algorithm.SchedulerExtender, volumeBinder *volumebinder.VolumeBinder) algorithm.ScheduleAlgorithm
func NewHTTPExtender ¶
func NewHTTPExtender(config *schedulerapi.ExtenderConfig) (algorithm.SchedulerExtender, error)
func NominatedNodeName ¶ added in v1.9.1
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
}
The AlgorithmCache stores PredicateMap with predicate name as key
type EquivalenceCache ¶
EquivalenceCache holds: 1. a map of AlgorithmCache with node name as key 2. function to get equivalence pod
func NewEquivalenceCache ¶
func NewEquivalenceCache(getEquivalencePodFunc algorithm.GetEquivalencePodFunc) *EquivalenceCache
func (*EquivalenceCache) InvalidateAllCachedPredicateItemOfNode ¶ added in v1.7.1
func (ec *EquivalenceCache) InvalidateAllCachedPredicateItemOfNode(nodeName string)
InvalidateAllCachedPredicateItemOfNode marks all cached items on given node as invalid
func (*EquivalenceCache) InvalidateCachedPredicateItem ¶ added in v1.7.1
func (ec *EquivalenceCache) InvalidateCachedPredicateItem(nodeName string, predicateKeys sets.String)
InvalidateCachedPredicateItem marks all items of given predicateKeys, of all pods, on the given node as invalid
func (*EquivalenceCache) InvalidateCachedPredicateItemForPodAdd ¶ added in v1.7.1
func (ec *EquivalenceCache) InvalidateCachedPredicateItemForPodAdd(pod *v1.Pod, nodeName string)
InvalidateCachedPredicateItemForPodAdd is a wrapper of InvalidateCachedPredicateItem for pod add case
func (*EquivalenceCache) InvalidateCachedPredicateItemOfAllNodes ¶ added in v1.7.1
func (ec *EquivalenceCache) InvalidateCachedPredicateItemOfAllNodes(predicateKeys sets.String)
InvalidateCachedPredicateItemOfAllNodes marks all items of given predicateKeys, of all pods, on all node as invalid
func (*EquivalenceCache) PredicateWithECache ¶ added in v1.7.1
func (ec *EquivalenceCache) PredicateWithECache( podName, nodeName, predicateKey string, equivalenceHash uint64, ) (bool, []algorithm.PredicateFailureReason, bool)
PredicateWithECache returns: 1. if fit 2. reasons if not fit 3. if this cache is invalid based on cached predicate results
func (*EquivalenceCache) UpdateCachedPredicateItem ¶ added in v1.7.1
func (ec *EquivalenceCache) UpdateCachedPredicateItem( podName, nodeName, predicateKey string, fit bool, reasons []algorithm.PredicateFailureReason, equivalenceHash uint64, )
UpdateCachedPredicateItem updates pod predicate for equivalence class
type FIFO ¶ added in v1.9.1
FIFO is basically a simple wrapper around cache.FIFO to make it compatible with the SchedulingQueue interface.
func (*FIFO) AddUnschedulableIfNotPresent ¶ added in v1.9.1
AddUnschedulableIfNotPresent adds an unschedulable pod back to the queue. In FIFO it is added to the end of the queue.
func (*FIFO) AssignedPodAdded ¶ added in v1.9.1
FIFO does not need to react to events, as all pods are always in the active scheduling queue anyway.
func (*FIFO) AssignedPodUpdated ¶ added in v1.9.1
func (*FIFO) MoveAllToActiveQueue ¶ added in v1.9.1
func (f *FIFO) MoveAllToActiveQueue()
MoveAllToActiveQueue does nothing in FIFO as all pods are always in the active queue.
func (*FIFO) Pop ¶ added in v1.9.1
Pop removes the head of FIFO and returns it. This is just a copy/paste of cache.Pop(queue Queue) from fifo.go that scheduler has always been using. There is a comment in that file saying that this method shouldn't be used in production code, but scheduler has always been using it. This function does minimal error checking.
type FailedPredicateMap ¶
type FailedPredicateMap map[string][]algorithm.PredicateFailureReason
type FitError ¶
type FitError struct { Pod *v1.Pod NumAllNodes int FailedPredicates FailedPredicateMap }
type HTTPExtender ¶
type HTTPExtender struct {
// contains filtered or unexported fields
}
HTTPExtender implements the algorithm.SchedulerExtender interface.
func (*HTTPExtender) Bind ¶ added in v1.7.1
func (h *HTTPExtender) Bind(binding *v1.Binding) error
Bind delegates the action of binding a pod to a node to the extender.
func (*HTTPExtender) Filter ¶
func (h *HTTPExtender) Filter(pod *v1.Pod, nodes []*v1.Node, nodeNameToInfo map[string]*schedulercache.NodeInfo) ([]*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) IsBinder ¶ added in v1.7.1
func (h *HTTPExtender) IsBinder() bool
IsBinder returns whether this extender is configured for the Bind method.
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 Heap ¶ added in v1.9.1
type Heap struct {
// contains filtered or unexported fields
}
Heap is a thread-safe producer/consumer queue that implements a heap data structure. It can be used to implement priority queues and similar data structures.
func (*Heap) Add ¶ added in v1.9.1
Add inserts an item, and puts it in the queue. The item is updated if it already exists.
func (*Heap) AddIfNotPresent ¶ added in v1.9.1
AddIfNotPresent inserts an item, and puts it in the queue. If an item with the key is present in the map, no changes is made to the item.
func (*Heap) List ¶ added in v1.9.1
func (h *Heap) List() []interface{}
List returns a list of all the items.
type HostPredicate ¶
type HostPredicate struct { Fit bool FailReasons []algorithm.PredicateFailureReason }
HostPredicate is the cached predicate result
type PredicateMap ¶ added in v1.7.1
type PredicateMap map[uint64]HostPredicate
PredicateMap stores HostPrediacte with equivalence hash as key
type PriorityQueue ¶ added in v1.9.1
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue implements a scheduling queue. It is an alternative to FIFO. The head of PriorityQueue is the highest priority pending pod. This structure has two sub queues. One sub-queue holds pods that are being considered for scheduling. This is called activeQ and is a Heap. Another queue holds pods that are already tried and are determined to be unschedulable. The latter is called unschedulableQ. Heap is already thread safe, but we need to acquire another lock here to ensure atomicity of operations on the two data structures..
func NewPriorityQueue ¶ added in v1.9.1
func NewPriorityQueue() *PriorityQueue
func (*PriorityQueue) Add ¶ added in v1.9.1
func (p *PriorityQueue) Add(pod *v1.Pod) error
Add adds a pod to the active queue. It should be called only when a new pod is added so there is no chance the pod is already in either queue.
func (*PriorityQueue) AddIfNotPresent ¶ added in v1.9.1
func (p *PriorityQueue) AddIfNotPresent(pod *v1.Pod) error
AddIfNotPresent adds a pod to the active queue if it is not present in any of the two queues. If it is present in any, it doesn't do any thing.
func (*PriorityQueue) AddUnschedulableIfNotPresent ¶ added in v1.9.1
func (p *PriorityQueue) AddUnschedulableIfNotPresent(pod *v1.Pod) error
AddUnschedulableIfNotPresent does nothing if the pod is present in either queue. Otherwise it adds the pod to the unschedulable queue if p.receivedMoveRequest is false, and to the activeQ if p.receivedMoveRequest is true.
func (*PriorityQueue) AssignedPodAdded ¶ added in v1.9.1
func (p *PriorityQueue) AssignedPodAdded(pod *v1.Pod)
AssignedPodAdded is called when a bound pod is added. Creation of this pod may make pending pods with matching affinity terms schedulable.
func (*PriorityQueue) AssignedPodUpdated ¶ added in v1.9.1
func (p *PriorityQueue) AssignedPodUpdated(pod *v1.Pod)
AssignedPodUpdated is called when a bound pod is updated. Change of labels may make pending pods with matching affinity terms schedulable.
func (*PriorityQueue) Delete ¶ added in v1.9.1
func (p *PriorityQueue) Delete(pod *v1.Pod) error
Delete deletes the item from either of the two queues. It assumes the pod is only in one queue.
func (*PriorityQueue) MoveAllToActiveQueue ¶ added in v1.9.1
func (p *PriorityQueue) MoveAllToActiveQueue()
MoveAllToActiveQueue moves all pods from unschedulableQ to activeQ. This function adds all pods and then signals the condition variable to ensure that if Pop() is waiting for an item, it receives it after all the pods are in the queue and the head is the highest priority pod. TODO(bsalamat): We should add a back-off mechanism here so that a high priority pod which is unschedulable does not go to the head of the queue frequently. For example in a cluster where a lot of pods being deleted, such a high priority pod can deprive other pods from getting scheduled.
func (*PriorityQueue) Pop ¶ added in v1.9.1
func (p *PriorityQueue) Pop() (*v1.Pod, error)
Pop removes the head of the active queue and returns it. It blocks if the activeQ is empty and waits until a new item is added to the queue. It also clears receivedMoveRequest to mark the beginning of a new scheduling cycle.
func (*PriorityQueue) Update ¶ added in v1.9.1
func (p *PriorityQueue) Update(pod *v1.Pod) error
Update updates a pod in the active queue if present. Otherwise, it removes the item from the unschedulable queue and adds the updated one to the active queue.
func (*PriorityQueue) WaitingPodsForNode ¶ added in v1.9.1
func (p *PriorityQueue) WaitingPodsForNode(nodeName string) []*v1.Pod
WaitingPodsForNode returns pods that are nominated to run on the given node, but they are waiting for other pods to be removed from the node before they can be actually scheduled.
type SchedulingQueue ¶ added in v1.9.1
type SchedulingQueue interface { Add(pod *v1.Pod) error AddIfNotPresent(pod *v1.Pod) error AddUnschedulableIfNotPresent(pod *v1.Pod) error Pop() (*v1.Pod, error) Update(pod *v1.Pod) error Delete(pod *v1.Pod) error MoveAllToActiveQueue() AssignedPodAdded(pod *v1.Pod) AssignedPodUpdated(pod *v1.Pod) WaitingPodsForNode(nodeName string) []*v1.Pod }
SchedulingQueue is an interface for a queue to store pods waiting to be scheduled. The interface follows a pattern similar to cache.FIFO and cache.Heap and makes it easy to use those data structures as a SchedulingQueue.
func NewSchedulingQueue ¶ added in v1.9.1
func NewSchedulingQueue() SchedulingQueue
NewSchedulingQueue initializes a new scheduling queue. If pod priority is enabled a priority queue is returned. If it is disabled, a FIFO is returned.
type UnschedulablePods ¶ added in v1.9.1
type UnschedulablePods interface { Add(pod *v1.Pod) Delete(pod *v1.Pod) Update(pod *v1.Pod) GetPodsWaitingForNode(nodeName string) []*v1.Pod Get(pod *v1.Pod) *v1.Pod Clear() }
UnschedulablePods is an interface for a queue that is used to keep unschedulable pods. These pods are not actively reevaluated for scheduling. They are moved to the active scheduling queue on certain events, such as termination of a pod in the cluster, addition of nodes, etc.
type UnschedulablePodsMap ¶ added in v1.9.1
type UnschedulablePodsMap struct {
// contains filtered or unexported fields
}
UnschedulablePodsMap holds pods that cannot be scheduled. This data structure is used to implement unschedulableQ.
func (*UnschedulablePodsMap) Add ¶ added in v1.9.1
func (u *UnschedulablePodsMap) Add(pod *v1.Pod)
Add adds a pod to the unschedulable pods.
func (*UnschedulablePodsMap) Clear ¶ added in v1.9.1
func (u *UnschedulablePodsMap) Clear()
Clear removes all the entries from the unschedulable maps.
func (*UnschedulablePodsMap) Delete ¶ added in v1.9.1
func (u *UnschedulablePodsMap) Delete(pod *v1.Pod)
Delete deletes a pod from the unschedulable pods.
func (*UnschedulablePodsMap) Get ¶ added in v1.9.1
func (u *UnschedulablePodsMap) Get(pod *v1.Pod) *v1.Pod
Get returns the pod if a pod with the same key as the key of the given "pod" is found in the map. It returns nil otherwise.
func (*UnschedulablePodsMap) GetPodsWaitingForNode ¶ added in v1.9.1
func (u *UnschedulablePodsMap) GetPodsWaitingForNode(nodeName string) []*v1.Pod
GetPodsWaitingForNode returns a list of unschedulable pods whose NominatedNodeNames are equal to the given nodeName.
func (*UnschedulablePodsMap) Update ¶ added in v1.9.1
func (u *UnschedulablePodsMap) Update(pod *v1.Pod)
Update updates a pod in the unschedulable pods.