mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
sched: support PreEnqueueChecks prior to moving Pods
This commit is contained in:
@@ -66,6 +66,11 @@ const (
|
||||
DefaultPodMaxBackoffDuration time.Duration = 10 * time.Second
|
||||
)
|
||||
|
||||
// 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 PreEnqueueCheck func(pod *v1.Pod) bool
|
||||
|
||||
// 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.
|
||||
@@ -85,7 +90,7 @@ type SchedulingQueue interface {
|
||||
Pop() (*framework.QueuedPodInfo, error)
|
||||
Update(oldPod, newPod *v1.Pod) error
|
||||
Delete(pod *v1.Pod) error
|
||||
MoveAllToActiveOrBackoffQueue(event string)
|
||||
MoveAllToActiveOrBackoffQueue(event string, preCheck PreEnqueueCheck)
|
||||
AssignedPodAdded(pod *v1.Pod)
|
||||
AssignedPodUpdated(pod *v1.Pod)
|
||||
PendingPods() []*v1.Pod
|
||||
@@ -523,12 +528,14 @@ func (p *PriorityQueue) AssignedPodUpdated(pod *v1.Pod) {
|
||||
// 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 (p *PriorityQueue) MoveAllToActiveOrBackoffQueue(event string) {
|
||||
func (p *PriorityQueue) MoveAllToActiveOrBackoffQueue(event string, preCheck PreEnqueueCheck) {
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
unschedulablePods := make([]*framework.QueuedPodInfo, 0, len(p.unschedulableQ.podInfoMap))
|
||||
for _, pInfo := range p.unschedulableQ.podInfoMap {
|
||||
unschedulablePods = append(unschedulablePods, pInfo)
|
||||
if preCheck == nil || preCheck(pInfo.Pod) {
|
||||
unschedulablePods = append(unschedulablePods, pInfo)
|
||||
}
|
||||
}
|
||||
p.movePodsToActiveOrBackoffQueue(unschedulablePods, event)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user