Documentation ¶
Index ¶
- Constants
- type Option
- func WithClock(clock clock.Clock) Option
- func WithMetricsRecorder(recorder metrics.MetricAsyncRecorder) Option
- func WithPluginMetricsSamplePercent(percent int) Option
- func WithPodInitialBackoffDuration(duration time.Duration) Option
- func WithPodLister(pl listersv1.PodLister) Option
- func WithPodMaxBackoffDuration(duration time.Duration) Option
- func WithPodMaxInUnschedulablePodsDuration(duration time.Duration) Option
- func WithPreEnqueuePluginMap(m map[string][]framework.PreEnqueuePlugin) Option
- func WithQueueingHintMapPerProfile(m QueueingHintMapPerProfile) Option
- type PreEnqueueCheck
- type PriorityQueue
- func NewPriorityQueue(lessFn framework.LessFunc, informerFactory informers.SharedInformerFactory, ...) *PriorityQueue
- func NewTestQueue(ctx context.Context, lessFn framework.LessFunc, opts ...Option) *PriorityQueue
- func NewTestQueueWithInformerFactory(ctx context.Context, lessFn framework.LessFunc, ...) *PriorityQueue
- func NewTestQueueWithObjects(ctx context.Context, lessFn framework.LessFunc, objs []runtime.Object, ...) *PriorityQueue
- func (p *PriorityQueue) Activate(logger klog.Logger, pods map[string]*v1.Pod)
- func (p *PriorityQueue) Add(logger klog.Logger, pod *v1.Pod)
- func (npm PriorityQueue) AddNominatedPod(logger klog.Logger, pi *framework.PodInfo, ...)
- func (p *PriorityQueue) AddUnschedulableIfNotPresent(logger klog.Logger, pInfo *framework.QueuedPodInfo, podSchedulingCycle int64) error
- func (p *PriorityQueue) AssignedPodAdded(logger klog.Logger, pod *v1.Pod)
- func (p *PriorityQueue) AssignedPodUpdated(logger klog.Logger, oldPod, newPod *v1.Pod, event framework.ClusterEvent)
- func (p *PriorityQueue) Close()
- func (p *PriorityQueue) Delete(pod *v1.Pod)
- func (npm PriorityQueue) DeleteNominatedPodIfExists(pod *v1.Pod)
- func (p *PriorityQueue) Done(pod types.UID)
- func (p *PriorityQueue) GetPod(name, namespace string) (pInfo *framework.QueuedPodInfo, ok bool)
- func (p *PriorityQueue) InFlightPods() []*v1.Pod
- func (p *PriorityQueue) MoveAllToActiveOrBackoffQueue(logger klog.Logger, event framework.ClusterEvent, oldObj, newObj interface{}, ...)
- func (p *PriorityQueue) NominatedPodsForNode(nodeName string) []*framework.PodInfo
- func (p *PriorityQueue) PendingPods() ([]*v1.Pod, string)
- func (p *PriorityQueue) PodsInActiveQ() []*v1.Pod
- func (p *PriorityQueue) Pop(logger klog.Logger) (*framework.QueuedPodInfo, error)
- func (p *PriorityQueue) Run(logger klog.Logger)
- func (p *PriorityQueue) SchedulingCycle() int64
- func (p *PriorityQueue) Update(logger klog.Logger, oldPod, newPod *v1.Pod)
- func (npm PriorityQueue) UpdateNominatedPod(logger klog.Logger, oldPod *v1.Pod, newPodInfo *framework.PodInfo)
- type QueueingHintFunction
- type QueueingHintMap
- type QueueingHintMapPerProfile
- type SchedulingQueue
- type UnschedulablePods
Constants ¶
const ( // DefaultPodInitialBackoffDuration is the default value for the initial backoff duration // for unschedulable pods. To change the default podInitialBackoffDurationSeconds used by the // scheduler, update the ComponentConfig value in defaults.go DefaultPodInitialBackoffDuration time.Duration = 1 * time.Second // DefaultPodMaxBackoffDuration is the default value for the max backoff duration // for unschedulable pods. To change the default podMaxBackoffDurationSeconds used by the // scheduler, update the ComponentConfig value in defaults.go DefaultPodMaxBackoffDuration time.Duration = 10 * time.Second )
const ( // DefaultPodMaxInUnschedulablePodsDuration is the default value for the maximum // time a pod can stay in unschedulablePods. If a pod stays in unschedulablePods // for longer than this value, the pod will be moved from unschedulablePods to // backoffQ or activeQ. If this value is empty, the default value (5min) // will be used. DefaultPodMaxInUnschedulablePodsDuration time.Duration = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*priorityQueueOptions)
Option configures a PriorityQueue
func WithMetricsRecorder ¶
func WithMetricsRecorder(recorder metrics.MetricAsyncRecorder) Option
WithMetricsRecorder sets metrics recorder.
func WithPluginMetricsSamplePercent ¶
WithPluginMetricsSamplePercent sets the percentage of plugin metrics to be sampled.
func WithPodInitialBackoffDuration ¶
WithPodInitialBackoffDuration sets pod initial backoff duration for PriorityQueue.
func WithPodLister ¶
WithPodLister sets pod lister for PriorityQueue.
func WithPodMaxBackoffDuration ¶
WithPodMaxBackoffDuration sets pod max backoff duration for PriorityQueue.
func WithPodMaxInUnschedulablePodsDuration ¶
WithPodMaxInUnschedulablePodsDuration sets podMaxInUnschedulablePodsDuration for PriorityQueue.
func WithPreEnqueuePluginMap ¶
func WithPreEnqueuePluginMap(m map[string][]framework.PreEnqueuePlugin) Option
WithPreEnqueuePluginMap sets preEnqueuePluginMap for PriorityQueue.
func WithQueueingHintMapPerProfile ¶
func WithQueueingHintMapPerProfile(m QueueingHintMapPerProfile) Option
WithQueueingHintMapPerProfile sets queueingHintMap for PriorityQueue.
type PreEnqueueCheck ¶
PreEnqueueCheck is a function type. It's used to build functions that run against a Pod and the caller can choose to enqueue or skip the Pod by the checking result.
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue implements a scheduling queue. The head of PriorityQueue is the highest priority pending pod. This structure has two sub queues and a additional data structure, namely: activeQ, backoffQ and unschedulablePods.
- activeQ holds pods that are being considered for scheduling.
- backoffQ holds pods that moved from unschedulablePods and will move to activeQ when their backoff periods complete.
- unschedulablePods holds pods that were already attempted for scheduling and are currently determined to be unschedulable.
func NewPriorityQueue ¶
func NewPriorityQueue( lessFn framework.LessFunc, informerFactory informers.SharedInformerFactory, opts ...Option, ) *PriorityQueue
NewPriorityQueue creates a PriorityQueue object.
func NewTestQueue ¶
NewTestQueue creates a priority queue with an empty informer factory.
func NewTestQueueWithInformerFactory ¶
func NewTestQueueWithInformerFactory( ctx context.Context, lessFn framework.LessFunc, informerFactory informers.SharedInformerFactory, opts ...Option, ) *PriorityQueue
func NewTestQueueWithObjects ¶
func NewTestQueueWithObjects( ctx context.Context, lessFn framework.LessFunc, objs []runtime.Object, opts ...Option, ) *PriorityQueue
NewTestQueueWithObjects creates a priority queue with an informer factory populated with the provided objects.
func (*PriorityQueue) Activate ¶
func (p *PriorityQueue) Activate(logger klog.Logger, pods map[string]*v1.Pod)
Activate moves the given pods to activeQ. If a pod isn't found in unschedulablePods or backoffQ and it's in-flight, the wildcard event is registered so that the pod will be requeued when it comes back. But, if a pod isn't found in unschedulablePods or backoffQ and it's not in-flight (i.e., completely unknown pod), Activate would ignore the pod.
func (*PriorityQueue) Add ¶
func (p *PriorityQueue) Add(logger klog.Logger, pod *v1.Pod)
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 active/unschedulable/backoff queues
func (PriorityQueue) AddNominatedPod ¶
func (npm PriorityQueue) AddNominatedPod(logger klog.Logger, pi *framework.PodInfo, nominatingInfo *framework.NominatingInfo)
AddNominatedPod adds a pod to the nominated pods of the given node. This is called during the preemption process after a node is nominated to run the pod. We update the structure before sending a request to update the pod object to avoid races with the following scheduling cycles.
func (*PriorityQueue) AddUnschedulableIfNotPresent ¶
func (p *PriorityQueue) AddUnschedulableIfNotPresent(logger klog.Logger, pInfo *framework.QueuedPodInfo, podSchedulingCycle int64) error
AddUnschedulableIfNotPresent inserts a pod that cannot be scheduled into the queue, unless it is already in the queue. Normally, PriorityQueue puts unschedulable pods in `unschedulablePods`. But if there has been a recent move request, then the pod is put in `podBackoffQ`.
func (*PriorityQueue) AssignedPodAdded ¶
func (p *PriorityQueue) AssignedPodAdded(logger klog.Logger, 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 ¶
func (p *PriorityQueue) AssignedPodUpdated(logger klog.Logger, oldPod, newPod *v1.Pod, event framework.ClusterEvent)
AssignedPodUpdated is called when a bound pod is updated. Change of labels may make pending pods with matching affinity terms schedulable.
func (*PriorityQueue) Delete ¶
func (p *PriorityQueue) Delete(pod *v1.Pod)
Delete deletes the item from either of the two queues. It assumes the pod is only in one queue.
func (PriorityQueue) DeleteNominatedPodIfExists ¶
DeleteNominatedPodIfExists deletes <pod> from nominatedPods.
func (*PriorityQueue) Done ¶
func (p *PriorityQueue) Done(pod types.UID)
Done must be called for pod returned by Pop. This allows the queue to keep track of which pods are currently being processed.
func (*PriorityQueue) GetPod ¶
func (p *PriorityQueue) GetPod(name, namespace string) (pInfo *framework.QueuedPodInfo, ok bool)
GetPod searches for a pod in the activeQ, backoffQ, and unschedulablePods.
func (*PriorityQueue) InFlightPods ¶
func (p *PriorityQueue) InFlightPods() []*v1.Pod
func (*PriorityQueue) MoveAllToActiveOrBackoffQueue ¶
func (p *PriorityQueue) MoveAllToActiveOrBackoffQueue(logger klog.Logger, event framework.ClusterEvent, oldObj, newObj interface{}, preCheck PreEnqueueCheck)
MoveAllToActiveOrBackoffQueue moves all pods from unschedulablePods to activeQ or backoffQ. This function adds all pods and then signals the condition variable to ensure that if Pop() is waiting for an item, it receives the signal after all the pods are in the queue and the head is the highest priority pod.
func (*PriorityQueue) NominatedPodsForNode ¶
func (p *PriorityQueue) NominatedPodsForNode(nodeName string) []*framework.PodInfo
NominatedPodsForNode returns a copy of pods that are nominated to run on the given node, but they are waiting for other pods to be removed from the node. CAUTION: Make sure you don't call this function while taking any queue's lock in any scenario.
func (*PriorityQueue) PendingPods ¶
func (p *PriorityQueue) PendingPods() ([]*v1.Pod, string)
PendingPods returns all the pending pods in the queue; accompanied by a debugging string recording showing the number of pods in each queue respectively. This function is used for debugging purposes in the scheduler cache dumper and comparer.
func (*PriorityQueue) PodsInActiveQ ¶
func (p *PriorityQueue) PodsInActiveQ() []*v1.Pod
PodsInActiveQ returns all the Pods in the activeQ.
func (*PriorityQueue) Pop ¶
func (p *PriorityQueue) Pop(logger klog.Logger) (*framework.QueuedPodInfo, 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 increments scheduling cycle when a pod is popped. Note: This method should NOT be locked by the p.lock at any moment, as it would lead to scheduling throughput degradation.
func (*PriorityQueue) Run ¶
func (p *PriorityQueue) Run(logger klog.Logger)
Run starts the goroutine to pump from podBackoffQ to activeQ
func (*PriorityQueue) SchedulingCycle ¶
func (p *PriorityQueue) SchedulingCycle() int64
SchedulingCycle returns current scheduling cycle.
func (*PriorityQueue) Update ¶
func (p *PriorityQueue) Update(logger klog.Logger, oldPod, newPod *v1.Pod)
Update updates a pod in the active or backoff queue if present. Otherwise, it removes the item from the unschedulable queue if pod is updated in a way that it may become schedulable and adds the updated one to the active queue. If pod is not present in any of the queues, it is added to the active queue.
type QueueingHintFunction ¶
type QueueingHintFunction struct { PluginName string QueueingHintFn framework.QueueingHintFn }
QueueingHintFunction is the wrapper of QueueingHintFn that has PluginName.
type QueueingHintMap ¶
type QueueingHintMap map[framework.ClusterEvent][]*QueueingHintFunction
QueueingHintMap is keyed with ClusterEvent, valued with queueing hint functions registered for the event.
type QueueingHintMapPerProfile ¶
type QueueingHintMapPerProfile map[string]QueueingHintMap
QueueingHintMapPerProfile is keyed with profile name, valued with queueing hint map registered for the profile.
type SchedulingQueue ¶
type SchedulingQueue interface { framework.PodNominator Add(logger klog.Logger, pod *v1.Pod) // Activate moves the given pods to activeQ. // If a pod isn't found in unschedulablePods or backoffQ and it's in-flight, // the wildcard event is registered so that the pod will be requeued when it comes back. // But, if a pod isn't found in unschedulablePods or backoffQ and it's not in-flight (i.e., completely unknown pod), // Activate would ignore the pod. Activate(logger klog.Logger, pods map[string]*v1.Pod) // AddUnschedulableIfNotPresent adds an unschedulable pod back to scheduling queue. // The podSchedulingCycle represents the current scheduling cycle number which can be // returned by calling SchedulingCycle(). AddUnschedulableIfNotPresent(logger klog.Logger, pod *framework.QueuedPodInfo, podSchedulingCycle int64) error // SchedulingCycle returns the current number of scheduling cycle which is // cached by scheduling queue. Normally, incrementing this number whenever // a pod is popped (e.g. called Pop()) is enough. SchedulingCycle() int64 // Pop removes the head of the queue and returns it. It blocks if the // queue is empty and waits until a new item is added to the queue. Pop(logger klog.Logger) (*framework.QueuedPodInfo, error) // Done must be called for pod returned by Pop. This allows the queue to // keep track of which pods are currently being processed. Done(types.UID) Update(logger klog.Logger, oldPod, newPod *v1.Pod) Delete(pod *v1.Pod) // Important Note: preCheck shouldn't include anything that depends on the in-tree plugins' logic. // (e.g., filter Pods based on added/updated Node's capacity, etc.) // We know currently some do, but we'll eventually remove them in favor of the scheduling queue hint. MoveAllToActiveOrBackoffQueue(logger klog.Logger, event framework.ClusterEvent, oldObj, newObj interface{}, preCheck PreEnqueueCheck) AssignedPodAdded(logger klog.Logger, pod *v1.Pod) AssignedPodUpdated(logger klog.Logger, oldPod, newPod *v1.Pod, event framework.ClusterEvent) // Close closes the SchedulingQueue so that the goroutine which is // waiting to pop items can exit gracefully. Close() // Run starts the goroutines managing the queue. Run(logger klog.Logger) // The following functions are supposed to be used only for testing or debugging. GetPod(name, namespace string) (*framework.QueuedPodInfo, bool) PendingPods() ([]*v1.Pod, string) InFlightPods() []*v1.Pod PodsInActiveQ() []*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 ¶
func NewSchedulingQueue( lessFn framework.LessFunc, informerFactory informers.SharedInformerFactory, opts ...Option) SchedulingQueue
NewSchedulingQueue initializes a priority queue as a new scheduling queue.
type UnschedulablePods ¶
type UnschedulablePods struct {
// contains filtered or unexported fields
}
UnschedulablePods holds pods that cannot be scheduled. This data structure is used to implement unschedulablePods.