kubernetes: k8s.io/kubernetes/pkg/scheduler/internal/queue Index | Files

package queue

import "k8s.io/kubernetes/pkg/scheduler/internal/queue"

Index

Package Files

events.go scheduling_queue.go

Constants

const (
    // Unknown event
    Unknown = "Unknown"
    // PodAdd is the event when a new pod is added to API server.
    PodAdd = "PodAdd"
    // NodeAdd is the event when a new node is added to the cluster.
    NodeAdd = "NodeAdd"
    // ScheduleAttemptFailure is the event when a schedule attempt fails.
    ScheduleAttemptFailure = "ScheduleAttemptFailure"
    // BackoffComplete is the event when a pod finishes backoff.
    BackoffComplete = "BackoffComplete"
    // UnschedulableTimeout is the event when a pod stays in unschedulable for longer than timeout.
    UnschedulableTimeout = "UnschedulableTimeout"
    // AssignedPodAdd is the event when a pod is added that causes pods with matching affinity terms
    // to be more schedulable.
    AssignedPodAdd = "AssignedPodAdd"
    // AssignedPodUpdate is the event when a pod is updated that causes pods with matching affinity
    // terms to be more schedulable.
    AssignedPodUpdate = "AssignedPodUpdate"
    // AssignedPodDelete is the event when a pod is deleted that causes pods with matching affinity
    // terms to be more schedulable.
    AssignedPodDelete = "AssignedPodDelete"
    // PvAdd is the event when a persistent volume is added in the cluster.
    PvAdd = "PvAdd"
    // PvUpdate is the event when a persistent volume is updated in the cluster.
    PvUpdate = "PvUpdate"
    // PvcAdd is the event when a persistent volume claim is added in the cluster.
    PvcAdd = "PvcAdd"
    // PvcUpdate is the event when a persistent volume claim is updated in the cluster.
    PvcUpdate = "PvcUpdate"
    // StorageClassAdd is the event when a StorageClass is added in the cluster.
    StorageClassAdd = "StorageClassAdd"
    // ServiceAdd is the event when a service is added in the cluster.
    ServiceAdd = "ServiceAdd"
    // ServiceUpdate is the event when a service is updated in the cluster.
    ServiceUpdate = "ServiceUpdate"
    // ServiceDelete is the event when a service is deleted in the cluster.
    ServiceDelete = "ServiceDelete"
    // CSINodeAdd is the event when a CSI node is added in the cluster.
    CSINodeAdd = "CSINodeAdd"
    // CSINodeUpdate is the event when a CSI node is updated in the cluster.
    CSINodeUpdate = "CSINodeUpdate"
    // NodeSpecUnschedulableChange is the event when unschedulable node spec is changed.
    NodeSpecUnschedulableChange = "NodeSpecUnschedulableChange"
    // NodeAllocatableChange is the event when node allocatable is changed.
    NodeAllocatableChange = "NodeAllocatableChange"
    // NodeLabelsChange is the event when node label is changed.
    NodeLabelChange = "NodeLabelChange"
    // NodeTaintsChange is the event when node taint is changed.
    NodeTaintChange = "NodeTaintChange"
    // NodeConditionChange is the event when node condition is changed.
    NodeConditionChange = "NodeConditionChange"
)

Events that trigger scheduler queue to change.

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
)

func MakeNextPodFunc Uses

func MakeNextPodFunc(queue SchedulingQueue) func() *framework.QueuedPodInfo

MakeNextPodFunc returns a function to retrieve the next pod from a given scheduling queue

func NewPodNominator Uses

func NewPodNominator() framework.PodNominator

NewPodNominator creates a nominatedPodMap as a backing of framework.PodNominator.

func NominatedNodeName Uses

func NominatedNodeName(pod *v1.Pod) string

NominatedNodeName returns nominated node name of a Pod.

type Option Uses

type Option func(*priorityQueueOptions)

Option configures a PriorityQueue

func WithClock Uses

func WithClock(clock util.Clock) Option

WithClock sets clock for PriorityQueue, the default clock is util.RealClock.

func WithPodInitialBackoffDuration Uses

func WithPodInitialBackoffDuration(duration time.Duration) Option

WithPodInitialBackoffDuration sets pod initial backoff duration for PriorityQueue.

func WithPodMaxBackoffDuration Uses

func WithPodMaxBackoffDuration(duration time.Duration) Option

WithPodMaxBackoffDuration sets pod max backoff duration for PriorityQueue.

func WithPodNominator Uses

func WithPodNominator(pn framework.PodNominator) Option

WithPodNominator sets pod nominator for PriorityQueue.

type PriorityQueue Uses

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 Uses

func NewPriorityQueue(
    lessFn framework.LessFunc,
    opts ...Option,
) *PriorityQueue

NewPriorityQueue creates a PriorityQueue object.

func (*PriorityQueue) Add Uses

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 Uses

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 Uses

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 Uses

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) Close Uses

func (p *PriorityQueue) Close()

Close closes the priority queue.

func (*PriorityQueue) Delete Uses

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 Uses

func (p *PriorityQueue) MoveAllToActiveOrBackoffQueue(event string)

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 Uses

func (p *PriorityQueue) NumUnschedulablePods() int

NumUnschedulablePods returns the number of unschedulable pods exist in the SchedulingQueue.

func (*PriorityQueue) PendingPods Uses

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 Uses

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 Uses

func (p *PriorityQueue) Run()

Run starts the goroutine to pump from podBackoffQ to activeQ

func (*PriorityQueue) SchedulingCycle Uses

func (p *PriorityQueue) SchedulingCycle() int64

SchedulingCycle returns current scheduling cycle.

func (*PriorityQueue) Update Uses

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 Uses

type SchedulingQueue interface {
    framework.PodNominator
    Add(pod *v1.Pod) error
    // 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 string)
    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 Uses

func NewSchedulingQueue(lessFn framework.LessFunc, opts ...Option) SchedulingQueue

NewSchedulingQueue initializes a priority queue as a new scheduling queue.

type UnschedulablePodsMap Uses

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

UnschedulablePodsMap holds pods that cannot be scheduled. This data structure is used to implement unschedulableQ.

Package queue imports 14 packages (graph) and is imported by 86 packages. Updated 2020-09-30. Refresh now. Tools for package owners.