Documentation ¶
Index ¶
- Constants
- Variables
- func MakeNextPodFunc(queue SchedulingQueue) func() *framework.QueuedPodInfo
- func NewPodNominator(podLister listersv1.PodLister) framework.PodNominator
- func NominatedNodeName(pod *v1.Pod) string
- type 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 NewTestQueueWithObjects(ctx context.Context, lessFn framework.LessFunc, objs []runtime.Object, ...) *PriorityQueue
- func (p *PriorityQueue) Activate(pods map[string]*v1.Pod)
- func (p *PriorityQueue) Add(pod *v1.Pod) error
- func (p *PriorityQueue) AddUnschedulableIfNotPresent(pInfo *framework.QueuedPodInfo, podSchedulingCycle int64) error
- func (p *PriorityQueue) AssignedPodAdded(pod *v1.Pod)
- func (p *PriorityQueue) AssignedPodUpdated(pod *v1.Pod)
- func (p *PriorityQueue) Close()
- func (p *PriorityQueue) Delete(pod *v1.Pod) error
- func (p *PriorityQueue) MoveAllToActiveOrBackoffQueue(event framework.ClusterEvent, preCheck PreEnqueueCheck)
- func (p *PriorityQueue) NumUnschedulablePods() int
- func (p *PriorityQueue) PendingPods() []*v1.Pod
- func (p *PriorityQueue) Pop() (*framework.QueuedPodInfo, error)
- func (p *PriorityQueue) Run()
- func (p *PriorityQueue) SchedulingCycle() int64
- func (p *PriorityQueue) Update(oldPod, newPod *v1.Pod) error
- type SchedulingQueue
- type UnschedulablePodsMap
Constants ¶
const ( // PodAdd is the event when a new pod is added to API server. PodAdd = "PodAdd" // ScheduleAttemptFailure is the event when a schedule attempt fails. ScheduleAttemptFailure = "ScheduleAttemptFailure" // BackoffComplete is the event when a pod finishes backoff. BackoffComplete = "BackoffComplete" // ForceActivate is the event when a pod is moved from unschedulableQ/backoffQ // to activeQ. Usually it's triggered by plugin implementations. ForceActivate = "ForceActivate" )
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 )
Variables ¶
var ( // AssignedPodAdd is the event when a pod is added that causes pods with matching affinity terms // to be more schedulable. AssignedPodAdd = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Add, Label: "AssignedPodAdd"} // NodeAdd is the event when a new node is added to the cluster. NodeAdd = framework.ClusterEvent{Resource: framework.Node, ActionType: framework.Add, Label: "NodeAdd"} // AssignedPodUpdate is the event when a pod is updated that causes pods with matching affinity // terms to be more schedulable. AssignedPodUpdate = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Update, Label: "AssignedPodUpdate"} // AssignedPodDelete is the event when a pod is deleted that causes pods with matching affinity // terms to be more schedulable. AssignedPodDelete = framework.ClusterEvent{Resource: framework.Pod, ActionType: framework.Delete, Label: "AssignedPodDelete"} // NodeSpecUnschedulableChange is the event when unschedulable node spec is changed. NodeSpecUnschedulableChange = framework.ClusterEvent{Resource: framework.Node, ActionType: framework.UpdateNodeTaint, Label: "NodeSpecUnschedulableChange"} // NodeAllocatableChange is the event when node allocatable is changed. NodeAllocatableChange = framework.ClusterEvent{Resource: framework.Node, ActionType: framework.UpdateNodeAllocatable, Label: "NodeAllocatableChange"} // NodeLabelChange is the event when node label is changed. NodeLabelChange = framework.ClusterEvent{Resource: framework.Node, ActionType: framework.UpdateNodeLabel, Label: "NodeLabelChange"} // NodeTaintChange is the event when node taint is changed. NodeTaintChange = framework.ClusterEvent{Resource: framework.Node, ActionType: framework.UpdateNodeTaint, Label: "NodeTaintChange"} // NodeConditionChange is the event when node condition is changed. NodeConditionChange = framework.ClusterEvent{Resource: framework.Node, ActionType: framework.UpdateNodeCondition, Label: "NodeConditionChange"} // PvAdd is the event when a persistent volume is added in the cluster. PvAdd = framework.ClusterEvent{Resource: framework.PersistentVolume, ActionType: framework.Add, Label: "PvAdd"} // PvUpdate is the event when a persistent volume is updated in the cluster. PvUpdate = framework.ClusterEvent{Resource: framework.PersistentVolume, ActionType: framework.Update, Label: "PvUpdate"} // PvcAdd is the event when a persistent volume claim is added in the cluster. PvcAdd = framework.ClusterEvent{Resource: framework.PersistentVolumeClaim, ActionType: framework.Add, Label: "PvcAdd"} // PvcUpdate is the event when a persistent volume claim is updated in the cluster. PvcUpdate = framework.ClusterEvent{Resource: framework.PersistentVolumeClaim, ActionType: framework.Update, Label: "PvcUpdate"} // StorageClassAdd is the event when a StorageClass is added in the cluster. StorageClassAdd = framework.ClusterEvent{Resource: framework.StorageClass, ActionType: framework.Add, Label: "StorageClassAdd"} // StorageClassUpdate is the event when a StorageClass is updated in the cluster. StorageClassUpdate = framework.ClusterEvent{Resource: framework.StorageClass, ActionType: framework.Update, Label: "StorageClassUpdate"} // CSINodeAdd is the event when a CSI node is added in the cluster. CSINodeAdd = framework.ClusterEvent{Resource: framework.CSINode, ActionType: framework.Add, Label: "CSINodeAdd"} // CSINodeUpdate is the event when a CSI node is updated in the cluster. CSINodeUpdate = framework.ClusterEvent{Resource: framework.CSINode, ActionType: framework.Update, Label: "CSINodeUpdate"} // CSIDriverAdd is the event when a CSI node is added in the cluster. CSIDriverAdd = framework.ClusterEvent{Resource: framework.CSIDriver, ActionType: framework.Add, Label: "CSIDriverAdd"} // CSIDriverUpdate is the event when a CSI node is updated in the cluster. CSIDriverUpdate = framework.ClusterEvent{Resource: framework.CSIDriver, ActionType: framework.Update, Label: "CSIDriverUpdate"} // CSIStorageCapacityAdd is the event when a CSI node is added in the cluster. CSIStorageCapacityAdd = framework.ClusterEvent{Resource: framework.CSIStorageCapacity, ActionType: framework.Add, Label: "CSIStorageCapacityAdd"} // CSIStorageCapacityUpdate is the event when a CSI node is updated in the cluster. CSIStorageCapacityUpdate = framework.ClusterEvent{Resource: framework.CSIStorageCapacity, ActionType: framework.Update, Label: "CSIStorageCapacityUpdate"} // ServiceAdd is the event when a service is added in the cluster. ServiceAdd = framework.ClusterEvent{Resource: framework.Service, ActionType: framework.Add, Label: "ServiceAdd"} // ServiceUpdate is the event when a service is updated in the cluster. ServiceUpdate = framework.ClusterEvent{Resource: framework.Service, ActionType: framework.Update, Label: "ServiceUpdate"} // ServiceDelete is the event when a service is deleted in the cluster. ServiceDelete = framework.ClusterEvent{Resource: framework.Service, ActionType: framework.Delete, Label: "ServiceDelete"} // WildCardEvent semantically matches all resources on all actions. WildCardEvent = framework.ClusterEvent{Resource: framework.WildCard, ActionType: framework.All, Label: "WildCardEvent"} // UnschedulableTimeout is the event when a pod stays in unschedulable for longer than timeout. UnschedulableTimeout = framework.ClusterEvent{Resource: framework.WildCard, ActionType: framework.All, Label: "UnschedulableTimeout"} )
Functions ¶
func MakeNextPodFunc ¶ added in v1.14.0
func MakeNextPodFunc(queue SchedulingQueue) func() *framework.QueuedPodInfo
MakeNextPodFunc returns a function to retrieve the next pod from a given scheduling queue
func NewPodNominator ¶ added in v1.19.0
func NewPodNominator(podLister listersv1.PodLister) framework.PodNominator
NewPodNominator creates a nominator as a backing of framework.PodNominator. A podLister is passed in so as to check if the pod exists before adding its nominatedNode info.
func NominatedNodeName ¶
NominatedNodeName returns nominated node name of a Pod.
Types ¶
type Option ¶ added in v1.17.0
type Option func(*priorityQueueOptions)
Option configures a PriorityQueue
func WithClock ¶ added in v1.17.0
WithClock sets clock for PriorityQueue, the default clock is util.RealClock.
func WithClusterEventMap ¶ added in v1.21.0
func WithClusterEventMap(m map[framework.ClusterEvent]sets.String) Option
WithClusterEventMap sets clusterEventMap for PriorityQueue.
func WithPodInitialBackoffDuration ¶ added in v1.17.0
WithPodInitialBackoffDuration sets pod initial backoff duration for PriorityQueue.
func WithPodMaxBackoffDuration ¶ added in v1.17.0
WithPodMaxBackoffDuration sets pod max backoff duration for PriorityQueue.
func WithPodNominator ¶ added in v1.19.0
func WithPodNominator(pn framework.PodNominator) Option
WithPodNominator sets pod nominator for PriorityQueue.
type PreEnqueueCheck ¶ added in v1.22.0
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 { // PodNominator abstracts the operations to maintain nominated Pods. framework.PodNominator // contains filtered or unexported fields }
PriorityQueue implements a scheduling queue. The head of PriorityQueue is the highest priority pending pod. This structure has three 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. The third queue holds pods that are moved from unschedulable queues and will be moved to active queue when backoff are completed.
func NewPriorityQueue ¶
func NewPriorityQueue( lessFn framework.LessFunc, informerFactory informers.SharedInformerFactory, opts ...Option, ) *PriorityQueue
NewPriorityQueue creates a PriorityQueue object.
func NewTestQueue ¶ added in v1.21.0
NewTestQueue creates a priority queue with an empty informer factory.
func NewTestQueueWithObjects ¶ added in v1.21.0
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 ¶ added in v1.22.0
func (p *PriorityQueue) Activate(pods map[string]*v1.Pod)
Activate moves the given pods to activeQ iff they're in unschedulableQ or backoffQ.
func (*PriorityQueue) Add ¶
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 active/unschedulable/backoff queues
func (*PriorityQueue) AddUnschedulableIfNotPresent ¶
func (p *PriorityQueue) AddUnschedulableIfNotPresent(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 `unschedulableQ`. But if there has been a recent move request, then the pod is put in `podBackoffQ`.
func (*PriorityQueue) AssignedPodAdded ¶
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 ¶
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 ¶
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) MoveAllToActiveOrBackoffQueue ¶ added in v1.17.0
func (p *PriorityQueue) MoveAllToActiveOrBackoffQueue(event framework.ClusterEvent, preCheck PreEnqueueCheck)
MoveAllToActiveOrBackoffQueue moves all pods from unschedulableQ 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 it after all the pods are in the queue and the head is the highest priority pod.
func (*PriorityQueue) NumUnschedulablePods ¶ added in v1.13.1
func (p *PriorityQueue) NumUnschedulablePods() int
NumUnschedulablePods returns the number of unschedulable pods exist in the SchedulingQueue.
func (*PriorityQueue) PendingPods ¶ added in v1.14.0
func (p *PriorityQueue) PendingPods() []*v1.Pod
PendingPods returns all the pending pods in the queue. This function is used for debugging purposes in the scheduler cache dumper and comparer.
func (*PriorityQueue) Pop ¶
func (p *PriorityQueue) Pop() (*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.
func (*PriorityQueue) Run ¶ added in v1.18.0
func (p *PriorityQueue) Run()
Run starts the goroutine to pump from podBackoffQ to activeQ
func (*PriorityQueue) SchedulingCycle ¶ added in v1.13.4
func (p *PriorityQueue) SchedulingCycle() int64
SchedulingCycle returns current scheduling cycle.
func (*PriorityQueue) Update ¶
func (p *PriorityQueue) Update(oldPod, newPod *v1.Pod) error
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 SchedulingQueue ¶
type SchedulingQueue interface { framework.PodNominator Add(pod *v1.Pod) error // Activate moves the given pods to activeQ iff they're in unschedulableQ or backoffQ. // The passed-in pods are originally compiled from plugins that want to activate Pods, // by injecting the pods through a reserved CycleState struct (PodsToActivate). Activate(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(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() (*framework.QueuedPodInfo, error) Update(oldPod, newPod *v1.Pod) error Delete(pod *v1.Pod) error MoveAllToActiveOrBackoffQueue(event framework.ClusterEvent, preCheck PreEnqueueCheck) AssignedPodAdded(pod *v1.Pod) AssignedPodUpdated(pod *v1.Pod) PendingPods() []*v1.Pod // Close closes the SchedulingQueue so that the goroutine which is // waiting to pop items can exit gracefully. Close() // NumUnschedulablePods returns the number of unschedulable pods exist in the SchedulingQueue. NumUnschedulablePods() int // Run starts the goroutines managing the queue. Run() }
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 UnschedulablePodsMap ¶
type UnschedulablePodsMap struct {
// contains filtered or unexported fields
}
UnschedulablePodsMap holds pods that cannot be scheduled. This data structure is used to implement unschedulableQ.