mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 19:23:40 +00:00
Merge pull request #108919 from denkensk/rename-usQ
Rename unschedulableQ to unschedulablePods
This commit is contained in:
commit
2161071d0b
@ -52,11 +52,11 @@ type Config struct {
|
|||||||
// LeaderElection is optional.
|
// LeaderElection is optional.
|
||||||
LeaderElection *leaderelection.LeaderElectionConfig
|
LeaderElection *leaderelection.LeaderElectionConfig
|
||||||
|
|
||||||
// PodMaxUnschedulableQDuration is the maximum time a pod can stay in
|
// PodMaxInUnschedulablePodsDuration is the maximum time a pod can stay in
|
||||||
// unschedulableQ. If a pod stays in unschedulableQ for longer than this
|
// unschedulablePods. If a pod stays in unschedulablePods for longer than this
|
||||||
// value, the pod will be moved from unschedulableQ to backoffQ or activeQ.
|
// value, the pod will be moved from unschedulablePods to backoffQ or activeQ.
|
||||||
// If this value is empty, the default value (60s) will be used.
|
// If this value is empty, the default value (5min) will be used.
|
||||||
PodMaxUnschedulableQDuration time.Duration
|
PodMaxInUnschedulablePodsDuration time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
type completedConfig struct {
|
type completedConfig struct {
|
||||||
|
@ -30,11 +30,11 @@ type DeprecatedOptions struct {
|
|||||||
componentbaseconfig.ClientConnectionConfiguration
|
componentbaseconfig.ClientConnectionConfiguration
|
||||||
// Note that only the deprecated options (lock-object-name and lock-object-namespace) are populated here.
|
// Note that only the deprecated options (lock-object-name and lock-object-namespace) are populated here.
|
||||||
componentbaseconfig.LeaderElectionConfiguration
|
componentbaseconfig.LeaderElectionConfiguration
|
||||||
// PodMaxUnschedulableQDuration is the maximum time a pod can stay in
|
// PodMaxInUnschedulablePodsDuration is the maximum time a pod can stay in
|
||||||
// unschedulableQ. If a pod stays in unschedulableQ for longer than this
|
// unschedulablePods. If a pod stays in unschedulablePods for longer than this
|
||||||
// value, the pod will be moved from unschedulableQ to backoffQ or activeQ.
|
// value, the pod will be moved from unschedulablePods to backoffQ or activeQ.
|
||||||
// If this value is empty, the default value (60s) will be used.
|
// If this value is empty, the default value (5min) will be used.
|
||||||
PodMaxUnschedulableQDuration time.Duration
|
PodMaxInUnschedulablePodsDuration time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddFlags adds flags for the deprecated options.
|
// AddFlags adds flags for the deprecated options.
|
||||||
@ -51,5 +51,5 @@ func (o *DeprecatedOptions) AddFlags(fs *pflag.FlagSet) {
|
|||||||
fs.Int32Var(&o.Burst, "kube-api-burst", 100, "DEPRECATED: burst to use while talking with kubernetes apiserver. This parameter is ignored if a config file is specified in --config.")
|
fs.Int32Var(&o.Burst, "kube-api-burst", 100, "DEPRECATED: burst to use while talking with kubernetes apiserver. This parameter is ignored if a config file is specified in --config.")
|
||||||
fs.StringVar(&o.ResourceNamespace, "lock-object-namespace", "kube-system", "DEPRECATED: define the namespace of the lock object. Will be removed in favor of leader-elect-resource-namespace. This parameter is ignored if a config file is specified in --config.")
|
fs.StringVar(&o.ResourceNamespace, "lock-object-namespace", "kube-system", "DEPRECATED: define the namespace of the lock object. Will be removed in favor of leader-elect-resource-namespace. This parameter is ignored if a config file is specified in --config.")
|
||||||
fs.StringVar(&o.ResourceName, "lock-object-name", "kube-scheduler", "DEPRECATED: define the name of the lock object. Will be removed in favor of leader-elect-resource-name. This parameter is ignored if a config file is specified in --config.")
|
fs.StringVar(&o.ResourceName, "lock-object-name", "kube-scheduler", "DEPRECATED: define the name of the lock object. Will be removed in favor of leader-elect-resource-name. This parameter is ignored if a config file is specified in --config.")
|
||||||
fs.DurationVar(&o.PodMaxUnschedulableQDuration, "pod-max-unschedulableq-duration", 5*time.Minute, "DEPRECATED: the maximum time a pod can stay in unschedulableQ. If a pod stays in unschedulableQ for longer than this value, the pod will be moved from unschedulableQ to backoffQ or activeQ. This flag is deprecated and will be removed in 1.26")
|
fs.DurationVar(&o.PodMaxInUnschedulablePodsDuration, "pod-max-in-unschedulable-pods-duration", 5*time.Minute, "DEPRECATED: 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. This flag is deprecated and will be removed in 1.26")
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func NewOptions() *Options {
|
|||||||
Authentication: apiserveroptions.NewDelegatingAuthenticationOptions(),
|
Authentication: apiserveroptions.NewDelegatingAuthenticationOptions(),
|
||||||
Authorization: apiserveroptions.NewDelegatingAuthorizationOptions(),
|
Authorization: apiserveroptions.NewDelegatingAuthorizationOptions(),
|
||||||
Deprecated: &DeprecatedOptions{
|
Deprecated: &DeprecatedOptions{
|
||||||
PodMaxUnschedulableQDuration: 5 * time.Minute,
|
PodMaxInUnschedulablePodsDuration: 5 * time.Minute,
|
||||||
},
|
},
|
||||||
LeaderElection: &componentbaseconfig.LeaderElectionConfiguration{
|
LeaderElection: &componentbaseconfig.LeaderElectionConfiguration{
|
||||||
LeaderElect: true,
|
LeaderElect: true,
|
||||||
@ -236,7 +236,7 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
|
|||||||
|
|
||||||
// Apply value independently instead of using ApplyDeprecated() because it can't be configured via ComponentConfig.
|
// Apply value independently instead of using ApplyDeprecated() because it can't be configured via ComponentConfig.
|
||||||
if o.Deprecated != nil {
|
if o.Deprecated != nil {
|
||||||
c.PodMaxUnschedulableQDuration = o.Deprecated.PodMaxUnschedulableQDuration
|
c.PodMaxInUnschedulablePodsDuration = o.Deprecated.PodMaxInUnschedulablePodsDuration
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -330,7 +330,7 @@ func Setup(ctx context.Context, opts *options.Options, outOfTreeRegistryOptions
|
|||||||
scheduler.WithFrameworkOutOfTreeRegistry(outOfTreeRegistry),
|
scheduler.WithFrameworkOutOfTreeRegistry(outOfTreeRegistry),
|
||||||
scheduler.WithPodMaxBackoffSeconds(cc.ComponentConfig.PodMaxBackoffSeconds),
|
scheduler.WithPodMaxBackoffSeconds(cc.ComponentConfig.PodMaxBackoffSeconds),
|
||||||
scheduler.WithPodInitialBackoffSeconds(cc.ComponentConfig.PodInitialBackoffSeconds),
|
scheduler.WithPodInitialBackoffSeconds(cc.ComponentConfig.PodInitialBackoffSeconds),
|
||||||
scheduler.WithPodMaxUnschedulableQDuration(cc.PodMaxUnschedulableQDuration),
|
scheduler.WithPodMaxInUnschedulablePodsDuration(cc.PodMaxInUnschedulablePodsDuration),
|
||||||
scheduler.WithExtenders(cc.ComponentConfig.Extenders...),
|
scheduler.WithExtenders(cc.ComponentConfig.Extenders...),
|
||||||
scheduler.WithParallelism(cc.ComponentConfig.Parallelism),
|
scheduler.WithParallelism(cc.ComponentConfig.Parallelism),
|
||||||
scheduler.WithBuildFrameworkCapturer(func(profile kubeschedulerconfig.KubeSchedulerProfile) {
|
scheduler.WithBuildFrameworkCapturer(func(profile kubeschedulerconfig.KubeSchedulerProfile) {
|
||||||
|
@ -108,7 +108,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// PodsToActivateKey is a reserved state key for stashing pods.
|
// PodsToActivateKey is a reserved state key for stashing pods.
|
||||||
// If the stashed pods are present in unschedulableQ or backoffQ,they will be
|
// If the stashed pods are present in unschedulablePods or backoffQ,they will be
|
||||||
// activated (i.e., moved to activeQ) in two phases:
|
// activated (i.e., moved to activeQ) in two phases:
|
||||||
// - end of a scheduling cycle if it succeeds (will be cleared from `PodsToActivate` if activated)
|
// - end of a scheduling cycle if it succeeds (will be cleared from `PodsToActivate` if activated)
|
||||||
// - end of a binding cycle if it succeeds
|
// - end of a binding cycle if it succeeds
|
||||||
|
@ -27,7 +27,7 @@ const (
|
|||||||
ScheduleAttemptFailure = "ScheduleAttemptFailure"
|
ScheduleAttemptFailure = "ScheduleAttemptFailure"
|
||||||
// BackoffComplete is the event when a pod finishes backoff.
|
// BackoffComplete is the event when a pod finishes backoff.
|
||||||
BackoffComplete = "BackoffComplete"
|
BackoffComplete = "BackoffComplete"
|
||||||
// ForceActivate is the event when a pod is moved from unschedulableQ/backoffQ
|
// ForceActivate is the event when a pod is moved from unschedulablePods/backoffQ
|
||||||
// to activeQ. Usually it's triggered by plugin implementations.
|
// to activeQ. Usually it's triggered by plugin implementations.
|
||||||
ForceActivate = "ForceActivate"
|
ForceActivate = "ForceActivate"
|
||||||
)
|
)
|
||||||
|
@ -15,11 +15,14 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// This file contains structures that implement scheduling queue types.
|
// This file contains structures that implement scheduling queue types.
|
||||||
// Scheduling queues hold pods waiting to be scheduled. This file implements a/
|
// Scheduling queues hold pods waiting to be scheduled. This file implements a
|
||||||
// priority queue which has two sub queues. One sub-queue holds pods that are
|
// priority queue which has two sub queues and a additional data structure,
|
||||||
// being considered for scheduling. This is called activeQ. Another queue holds
|
// namely: activeQ, backoffQ and unschedulablePods.
|
||||||
// pods that are already tried and are determined to be unschedulable. The latter
|
// - activeQ holds pods that are being considered for scheduling.
|
||||||
// is called unschedulableQ.
|
// - 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.
|
||||||
|
|
||||||
package queue
|
package queue
|
||||||
|
|
||||||
@ -46,12 +49,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// DefaultPodMaxUnschedulableQDuration is the default value for the maximum
|
// DefaultPodMaxInUnschedulablePodsDuration is the default value for the maximum
|
||||||
// time a pod can stay in unschedulableQ. If a pod stays in unschedulableQ
|
// time a pod can stay in unschedulablePods. If a pod stays in unschedulablePods
|
||||||
// for longer than this value, the pod will be moved from unschedulableQ to
|
// 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)
|
// backoffQ or activeQ. If this value is empty, the default value (5min)
|
||||||
// will be used.
|
// will be used.
|
||||||
DefaultPodMaxUnschedulableQDuration time.Duration = 5 * time.Minute
|
DefaultPodMaxInUnschedulablePodsDuration time.Duration = 5 * time.Minute
|
||||||
|
|
||||||
queueClosed = "scheduling queue is closed"
|
queueClosed = "scheduling queue is closed"
|
||||||
)
|
)
|
||||||
@ -78,7 +81,7 @@ type PreEnqueueCheck func(pod *v1.Pod) bool
|
|||||||
type SchedulingQueue interface {
|
type SchedulingQueue interface {
|
||||||
framework.PodNominator
|
framework.PodNominator
|
||||||
Add(pod *v1.Pod) error
|
Add(pod *v1.Pod) error
|
||||||
// Activate moves the given pods to activeQ iff they're in unschedulableQ or backoffQ.
|
// Activate moves the given pods to activeQ iff they're in unschedulablePods or backoffQ.
|
||||||
// The passed-in pods are originally compiled from plugins that want to activate Pods,
|
// The passed-in pods are originally compiled from plugins that want to activate Pods,
|
||||||
// by injecting the pods through a reserved CycleState struct (PodsToActivate).
|
// by injecting the pods through a reserved CycleState struct (PodsToActivate).
|
||||||
Activate(pods map[string]*v1.Pod)
|
Activate(pods map[string]*v1.Pod)
|
||||||
@ -121,11 +124,13 @@ func NominatedNodeName(pod *v1.Pod) string {
|
|||||||
|
|
||||||
// PriorityQueue implements a scheduling queue.
|
// PriorityQueue implements a scheduling queue.
|
||||||
// The head of PriorityQueue is the highest priority pending pod. This structure
|
// 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
|
// has two sub queues and a additional data structure, namely: activeQ,
|
||||||
// scheduling. This is called activeQ and is a Heap. Another queue holds
|
// backoffQ and unschedulablePods.
|
||||||
// pods that are already tried and are determined to be unschedulable. The latter
|
// - activeQ holds pods that are being considered for scheduling.
|
||||||
// is called unschedulableQ. The third queue holds pods that are moved from
|
// - backoffQ holds pods that moved from unschedulablePods and will move to
|
||||||
// unschedulable queues and will be moved to active queue when backoff are completed.
|
// activeQ when their backoff periods complete.
|
||||||
|
// - unschedulablePods holds pods that were already attempted for scheduling and
|
||||||
|
// are currently determined to be unschedulable.
|
||||||
type PriorityQueue struct {
|
type PriorityQueue struct {
|
||||||
// PodNominator abstracts the operations to maintain nominated Pods.
|
// PodNominator abstracts the operations to maintain nominated Pods.
|
||||||
framework.PodNominator
|
framework.PodNominator
|
||||||
@ -137,8 +142,8 @@ type PriorityQueue struct {
|
|||||||
podInitialBackoffDuration time.Duration
|
podInitialBackoffDuration time.Duration
|
||||||
// pod maximum backoff duration.
|
// pod maximum backoff duration.
|
||||||
podMaxBackoffDuration time.Duration
|
podMaxBackoffDuration time.Duration
|
||||||
// the maximum time a pod can stay in the unschedulableQ.
|
// the maximum time a pod can stay in the unschedulablePods.
|
||||||
podMaxUnschedulableQDuration time.Duration
|
podMaxInUnschedulablePodsDuration time.Duration
|
||||||
|
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
cond sync.Cond
|
cond sync.Cond
|
||||||
@ -149,8 +154,8 @@ type PriorityQueue struct {
|
|||||||
// podBackoffQ is a heap ordered by backoff expiry. Pods which have completed backoff
|
// podBackoffQ is a heap ordered by backoff expiry. Pods which have completed backoff
|
||||||
// are popped from this heap before the scheduler looks at activeQ
|
// are popped from this heap before the scheduler looks at activeQ
|
||||||
podBackoffQ *heap.Heap
|
podBackoffQ *heap.Heap
|
||||||
// unschedulableQ holds pods that have been tried and determined unschedulable.
|
// unschedulablePods holds pods that have been tried and determined unschedulable.
|
||||||
unschedulableQ *UnschedulablePodsMap
|
unschedulablePods *UnschedulablePods
|
||||||
// schedulingCycle represents sequence number of scheduling cycle and is incremented
|
// schedulingCycle represents sequence number of scheduling cycle and is incremented
|
||||||
// when a pod is popped.
|
// when a pod is popped.
|
||||||
schedulingCycle int64
|
schedulingCycle int64
|
||||||
@ -173,7 +178,7 @@ type priorityQueueOptions struct {
|
|||||||
clock util.Clock
|
clock util.Clock
|
||||||
podInitialBackoffDuration time.Duration
|
podInitialBackoffDuration time.Duration
|
||||||
podMaxBackoffDuration time.Duration
|
podMaxBackoffDuration time.Duration
|
||||||
podMaxUnschedulableQDuration time.Duration
|
podMaxInUnschedulablePodsDuration time.Duration
|
||||||
podNominator framework.PodNominator
|
podNominator framework.PodNominator
|
||||||
clusterEventMap map[framework.ClusterEvent]sets.String
|
clusterEventMap map[framework.ClusterEvent]sets.String
|
||||||
}
|
}
|
||||||
@ -216,10 +221,10 @@ func WithClusterEventMap(m map[framework.ClusterEvent]sets.String) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithPodMaxUnschedulableQDuration sets podMaxUnschedulableQDuration for PriorityQueue.
|
// WithPodMaxInUnschedulablePodsDuration sets podMaxInUnschedulablePodsDuration for PriorityQueue.
|
||||||
func WithPodMaxUnschedulableQDuration(duration time.Duration) Option {
|
func WithPodMaxInUnschedulablePodsDuration(duration time.Duration) Option {
|
||||||
return func(o *priorityQueueOptions) {
|
return func(o *priorityQueueOptions) {
|
||||||
o.podMaxUnschedulableQDuration = duration
|
o.podMaxInUnschedulablePodsDuration = duration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +232,7 @@ var defaultPriorityQueueOptions = priorityQueueOptions{
|
|||||||
clock: util.RealClock{},
|
clock: util.RealClock{},
|
||||||
podInitialBackoffDuration: DefaultPodInitialBackoffDuration,
|
podInitialBackoffDuration: DefaultPodInitialBackoffDuration,
|
||||||
podMaxBackoffDuration: DefaultPodMaxBackoffDuration,
|
podMaxBackoffDuration: DefaultPodMaxBackoffDuration,
|
||||||
podMaxUnschedulableQDuration: DefaultPodMaxUnschedulableQDuration,
|
podMaxInUnschedulablePodsDuration: DefaultPodMaxInUnschedulablePodsDuration,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Making sure that PriorityQueue implements SchedulingQueue.
|
// Making sure that PriorityQueue implements SchedulingQueue.
|
||||||
@ -270,9 +275,9 @@ func NewPriorityQueue(
|
|||||||
stop: make(chan struct{}),
|
stop: make(chan struct{}),
|
||||||
podInitialBackoffDuration: options.podInitialBackoffDuration,
|
podInitialBackoffDuration: options.podInitialBackoffDuration,
|
||||||
podMaxBackoffDuration: options.podMaxBackoffDuration,
|
podMaxBackoffDuration: options.podMaxBackoffDuration,
|
||||||
podMaxUnschedulableQDuration: options.podMaxUnschedulableQDuration,
|
podMaxInUnschedulablePodsDuration: options.podMaxInUnschedulablePodsDuration,
|
||||||
activeQ: heap.NewWithRecorder(podInfoKeyFunc, comp, metrics.NewActivePodsRecorder()),
|
activeQ: heap.NewWithRecorder(podInfoKeyFunc, comp, metrics.NewActivePodsRecorder()),
|
||||||
unschedulableQ: newUnschedulablePodsMap(metrics.NewUnschedulablePodsRecorder()),
|
unschedulablePods: newUnschedulablePods(metrics.NewUnschedulablePodsRecorder()),
|
||||||
moveRequestCycle: -1,
|
moveRequestCycle: -1,
|
||||||
clusterEventMap: options.clusterEventMap,
|
clusterEventMap: options.clusterEventMap,
|
||||||
}
|
}
|
||||||
@ -286,7 +291,7 @@ func NewPriorityQueue(
|
|||||||
// Run starts the goroutine to pump from podBackoffQ to activeQ
|
// Run starts the goroutine to pump from podBackoffQ to activeQ
|
||||||
func (p *PriorityQueue) Run() {
|
func (p *PriorityQueue) Run() {
|
||||||
go wait.Until(p.flushBackoffQCompleted, 1.0*time.Second, p.stop)
|
go wait.Until(p.flushBackoffQCompleted, 1.0*time.Second, p.stop)
|
||||||
go wait.Until(p.flushUnschedulableQLeftover, 30*time.Second, p.stop)
|
go wait.Until(p.flushUnschedulablePodsLeftover, 30*time.Second, p.stop)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add adds a pod to the active queue. It should be called only when a new pod
|
// Add adds a pod to the active queue. It should be called only when a new pod
|
||||||
@ -299,9 +304,9 @@ func (p *PriorityQueue) Add(pod *v1.Pod) error {
|
|||||||
klog.ErrorS(err, "Error adding pod to the active queue", "pod", klog.KObj(pod))
|
klog.ErrorS(err, "Error adding pod to the active queue", "pod", klog.KObj(pod))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if p.unschedulableQ.get(pod) != nil {
|
if p.unschedulablePods.get(pod) != nil {
|
||||||
klog.ErrorS(nil, "Error: pod is already in the unschedulable queue", "pod", klog.KObj(pod))
|
klog.ErrorS(nil, "Error: pod is already in the unschedulable queue", "pod", klog.KObj(pod))
|
||||||
p.unschedulableQ.delete(pod)
|
p.unschedulablePods.delete(pod)
|
||||||
}
|
}
|
||||||
// Delete pod from backoffQ if it is backing off
|
// Delete pod from backoffQ if it is backing off
|
||||||
if err := p.podBackoffQ.Delete(pInfo); err == nil {
|
if err := p.podBackoffQ.Delete(pInfo); err == nil {
|
||||||
@ -314,7 +319,7 @@ func (p *PriorityQueue) Add(pod *v1.Pod) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activate moves the given pods to activeQ iff they're in unschedulableQ or backoffQ.
|
// Activate moves the given pods to activeQ iff they're in unschedulablePods or backoffQ.
|
||||||
func (p *PriorityQueue) Activate(pods map[string]*v1.Pod) {
|
func (p *PriorityQueue) Activate(pods map[string]*v1.Pod) {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
@ -338,11 +343,11 @@ func (p *PriorityQueue) activate(pod *v1.Pod) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
var pInfo *framework.QueuedPodInfo
|
var pInfo *framework.QueuedPodInfo
|
||||||
// Verify if the pod is present in unschedulableQ or backoffQ.
|
// Verify if the pod is present in unschedulablePods or backoffQ.
|
||||||
if pInfo = p.unschedulableQ.get(pod); pInfo == nil {
|
if pInfo = p.unschedulablePods.get(pod); pInfo == nil {
|
||||||
// If the pod doesn't belong to unschedulableQ or backoffQ, don't activate it.
|
// If the pod doesn't belong to unschedulablePods or backoffQ, don't activate it.
|
||||||
if obj, exists, _ := p.podBackoffQ.Get(newQueuedPodInfoForLookup(pod)); !exists {
|
if obj, exists, _ := p.podBackoffQ.Get(newQueuedPodInfoForLookup(pod)); !exists {
|
||||||
klog.ErrorS(nil, "To-activate pod does not exist in unschedulableQ or backoffQ", "pod", klog.KObj(pod))
|
klog.ErrorS(nil, "To-activate pod does not exist in unschedulablePods or backoffQ", "pod", klog.KObj(pod))
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
pInfo = obj.(*framework.QueuedPodInfo)
|
pInfo = obj.(*framework.QueuedPodInfo)
|
||||||
@ -359,7 +364,7 @@ func (p *PriorityQueue) activate(pod *v1.Pod) bool {
|
|||||||
klog.ErrorS(err, "Error adding pod to the scheduling queue", "pod", klog.KObj(pod))
|
klog.ErrorS(err, "Error adding pod to the scheduling queue", "pod", klog.KObj(pod))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
p.unschedulableQ.delete(pod)
|
p.unschedulablePods.delete(pod)
|
||||||
p.podBackoffQ.Delete(pInfo)
|
p.podBackoffQ.Delete(pInfo)
|
||||||
metrics.SchedulerQueueIncomingPods.WithLabelValues("active", ForceActivate).Inc()
|
metrics.SchedulerQueueIncomingPods.WithLabelValues("active", ForceActivate).Inc()
|
||||||
p.PodNominator.AddNominatedPod(pInfo.PodInfo, nil)
|
p.PodNominator.AddNominatedPod(pInfo.PodInfo, nil)
|
||||||
@ -382,13 +387,13 @@ func (p *PriorityQueue) SchedulingCycle() int64 {
|
|||||||
|
|
||||||
// AddUnschedulableIfNotPresent inserts a pod that cannot be scheduled into
|
// AddUnschedulableIfNotPresent inserts a pod that cannot be scheduled into
|
||||||
// the queue, unless it is already in the queue. Normally, PriorityQueue puts
|
// the queue, unless it is already in the queue. Normally, PriorityQueue puts
|
||||||
// unschedulable pods in `unschedulableQ`. But if there has been a recent move
|
// unschedulable pods in `unschedulablePods`. But if there has been a recent move
|
||||||
// request, then the pod is put in `podBackoffQ`.
|
// request, then the pod is put in `podBackoffQ`.
|
||||||
func (p *PriorityQueue) AddUnschedulableIfNotPresent(pInfo *framework.QueuedPodInfo, podSchedulingCycle int64) error {
|
func (p *PriorityQueue) AddUnschedulableIfNotPresent(pInfo *framework.QueuedPodInfo, podSchedulingCycle int64) error {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
pod := pInfo.Pod
|
pod := pInfo.Pod
|
||||||
if p.unschedulableQ.get(pod) != nil {
|
if p.unschedulablePods.get(pod) != nil {
|
||||||
return fmt.Errorf("Pod %v is already present in unschedulable queue", klog.KObj(pod))
|
return fmt.Errorf("Pod %v is already present in unschedulable queue", klog.KObj(pod))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +408,7 @@ func (p *PriorityQueue) AddUnschedulableIfNotPresent(pInfo *framework.QueuedPodI
|
|||||||
pInfo.Timestamp = p.clock.Now()
|
pInfo.Timestamp = p.clock.Now()
|
||||||
|
|
||||||
// If a move request has been received, move it to the BackoffQ, otherwise move
|
// If a move request has been received, move it to the BackoffQ, otherwise move
|
||||||
// it to unschedulableQ.
|
// it to unschedulablePods.
|
||||||
for plugin := range pInfo.UnschedulablePlugins {
|
for plugin := range pInfo.UnschedulablePlugins {
|
||||||
metrics.UnschedulableReason(plugin, pInfo.Pod.Spec.SchedulerName).Inc()
|
metrics.UnschedulableReason(plugin, pInfo.Pod.Spec.SchedulerName).Inc()
|
||||||
}
|
}
|
||||||
@ -413,7 +418,7 @@ func (p *PriorityQueue) AddUnschedulableIfNotPresent(pInfo *framework.QueuedPodI
|
|||||||
}
|
}
|
||||||
metrics.SchedulerQueueIncomingPods.WithLabelValues("backoff", ScheduleAttemptFailure).Inc()
|
metrics.SchedulerQueueIncomingPods.WithLabelValues("backoff", ScheduleAttemptFailure).Inc()
|
||||||
} else {
|
} else {
|
||||||
p.unschedulableQ.addOrUpdate(pInfo)
|
p.unschedulablePods.addOrUpdate(pInfo)
|
||||||
metrics.SchedulerQueueIncomingPods.WithLabelValues("unschedulable", ScheduleAttemptFailure).Inc()
|
metrics.SchedulerQueueIncomingPods.WithLabelValues("unschedulable", ScheduleAttemptFailure).Inc()
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -452,17 +457,17 @@ func (p *PriorityQueue) flushBackoffQCompleted() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// flushUnschedulableQLeftover moves pods which stay in unschedulableQ longer than podMaxUnschedulableQDuration
|
// flushUnschedulablePodsLeftover moves pods which stay in unschedulablePods
|
||||||
// to backoffQ or activeQ.
|
// longer than podMaxInUnschedulablePodsDuration to backoffQ or activeQ.
|
||||||
func (p *PriorityQueue) flushUnschedulableQLeftover() {
|
func (p *PriorityQueue) flushUnschedulablePodsLeftover() {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
|
|
||||||
var podsToMove []*framework.QueuedPodInfo
|
var podsToMove []*framework.QueuedPodInfo
|
||||||
currentTime := p.clock.Now()
|
currentTime := p.clock.Now()
|
||||||
for _, pInfo := range p.unschedulableQ.podInfoMap {
|
for _, pInfo := range p.unschedulablePods.podInfoMap {
|
||||||
lastScheduleTime := pInfo.Timestamp
|
lastScheduleTime := pInfo.Timestamp
|
||||||
if currentTime.Sub(lastScheduleTime) > p.podMaxUnschedulableQDuration {
|
if currentTime.Sub(lastScheduleTime) > p.podMaxInUnschedulablePodsDuration {
|
||||||
podsToMove = append(podsToMove, pInfo)
|
podsToMove = append(podsToMove, pInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -538,7 +543,7 @@ func (p *PriorityQueue) Update(oldPod, newPod *v1.Pod) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the pod is in the unschedulable queue, updating it may make it schedulable.
|
// If the pod is in the unschedulable queue, updating it may make it schedulable.
|
||||||
if usPodInfo := p.unschedulableQ.get(newPod); usPodInfo != nil {
|
if usPodInfo := p.unschedulablePods.get(newPod); usPodInfo != nil {
|
||||||
pInfo := updatePod(usPodInfo, newPod)
|
pInfo := updatePod(usPodInfo, newPod)
|
||||||
p.PodNominator.UpdateNominatedPod(oldPod, pInfo.PodInfo)
|
p.PodNominator.UpdateNominatedPod(oldPod, pInfo.PodInfo)
|
||||||
if isPodUpdated(oldPod, newPod) {
|
if isPodUpdated(oldPod, newPod) {
|
||||||
@ -546,17 +551,17 @@ func (p *PriorityQueue) Update(oldPod, newPod *v1.Pod) error {
|
|||||||
if err := p.podBackoffQ.Add(pInfo); err != nil {
|
if err := p.podBackoffQ.Add(pInfo); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
p.unschedulableQ.delete(usPodInfo.Pod)
|
p.unschedulablePods.delete(usPodInfo.Pod)
|
||||||
} else {
|
} else {
|
||||||
if err := p.activeQ.Add(pInfo); err != nil {
|
if err := p.activeQ.Add(pInfo); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
p.unschedulableQ.delete(usPodInfo.Pod)
|
p.unschedulablePods.delete(usPodInfo.Pod)
|
||||||
p.cond.Broadcast()
|
p.cond.Broadcast()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Pod update didn't make it schedulable, keep it in the unschedulable queue.
|
// Pod update didn't make it schedulable, keep it in the unschedulable queue.
|
||||||
p.unschedulableQ.addOrUpdate(pInfo)
|
p.unschedulablePods.addOrUpdate(pInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -580,7 +585,7 @@ func (p *PriorityQueue) Delete(pod *v1.Pod) error {
|
|||||||
if err := p.activeQ.Delete(newQueuedPodInfoForLookup(pod)); err != nil {
|
if err := p.activeQ.Delete(newQueuedPodInfoForLookup(pod)); err != nil {
|
||||||
// The item was probably not found in the activeQ.
|
// The item was probably not found in the activeQ.
|
||||||
p.podBackoffQ.Delete(newQueuedPodInfoForLookup(pod))
|
p.podBackoffQ.Delete(newQueuedPodInfoForLookup(pod))
|
||||||
p.unschedulableQ.delete(pod)
|
p.unschedulablePods.delete(pod)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -601,15 +606,15 @@ func (p *PriorityQueue) AssignedPodUpdated(pod *v1.Pod) {
|
|||||||
p.lock.Unlock()
|
p.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MoveAllToActiveOrBackoffQueue moves all pods from unschedulableQ to activeQ or backoffQ.
|
// MoveAllToActiveOrBackoffQueue moves all pods from unschedulablePods to activeQ or backoffQ.
|
||||||
// This function adds all pods and then signals the condition variable to ensure that
|
// 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
|
// 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.
|
// queue and the head is the highest priority pod.
|
||||||
func (p *PriorityQueue) MoveAllToActiveOrBackoffQueue(event framework.ClusterEvent, preCheck PreEnqueueCheck) {
|
func (p *PriorityQueue) MoveAllToActiveOrBackoffQueue(event framework.ClusterEvent, preCheck PreEnqueueCheck) {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
unschedulablePods := make([]*framework.QueuedPodInfo, 0, len(p.unschedulableQ.podInfoMap))
|
unschedulablePods := make([]*framework.QueuedPodInfo, 0, len(p.unschedulablePods.podInfoMap))
|
||||||
for _, pInfo := range p.unschedulableQ.podInfoMap {
|
for _, pInfo := range p.unschedulablePods.podInfoMap {
|
||||||
if preCheck == nil || preCheck(pInfo.Pod) {
|
if preCheck == nil || preCheck(pInfo.Pod) {
|
||||||
unschedulablePods = append(unschedulablePods, pInfo)
|
unschedulablePods = append(unschedulablePods, pInfo)
|
||||||
}
|
}
|
||||||
@ -635,14 +640,14 @@ func (p *PriorityQueue) movePodsToActiveOrBackoffQueue(podInfoList []*framework.
|
|||||||
klog.ErrorS(err, "Error adding pod to the backoff queue", "pod", klog.KObj(pod))
|
klog.ErrorS(err, "Error adding pod to the backoff queue", "pod", klog.KObj(pod))
|
||||||
} else {
|
} else {
|
||||||
metrics.SchedulerQueueIncomingPods.WithLabelValues("backoff", event.Label).Inc()
|
metrics.SchedulerQueueIncomingPods.WithLabelValues("backoff", event.Label).Inc()
|
||||||
p.unschedulableQ.delete(pod)
|
p.unschedulablePods.delete(pod)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := p.activeQ.Add(pInfo); err != nil {
|
if err := p.activeQ.Add(pInfo); err != nil {
|
||||||
klog.ErrorS(err, "Error adding pod to the scheduling queue", "pod", klog.KObj(pod))
|
klog.ErrorS(err, "Error adding pod to the scheduling queue", "pod", klog.KObj(pod))
|
||||||
} else {
|
} else {
|
||||||
metrics.SchedulerQueueIncomingPods.WithLabelValues("active", event.Label).Inc()
|
metrics.SchedulerQueueIncomingPods.WithLabelValues("active", event.Label).Inc()
|
||||||
p.unschedulableQ.delete(pod)
|
p.unschedulablePods.delete(pod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -660,7 +665,7 @@ func (p *PriorityQueue) getUnschedulablePodsWithMatchingAffinityTerm(pod *v1.Pod
|
|||||||
nsLabels = interpodaffinity.GetNamespaceLabelsSnapshot(pod.Namespace, p.nsLister)
|
nsLabels = interpodaffinity.GetNamespaceLabelsSnapshot(pod.Namespace, p.nsLister)
|
||||||
|
|
||||||
var podsToMove []*framework.QueuedPodInfo
|
var podsToMove []*framework.QueuedPodInfo
|
||||||
for _, pInfo := range p.unschedulableQ.podInfoMap {
|
for _, pInfo := range p.unschedulablePods.podInfoMap {
|
||||||
for _, term := range pInfo.RequiredAffinityTerms {
|
for _, term := range pInfo.RequiredAffinityTerms {
|
||||||
if term.Matches(pod, nsLabels) {
|
if term.Matches(pod, nsLabels) {
|
||||||
podsToMove = append(podsToMove, pInfo)
|
podsToMove = append(podsToMove, pInfo)
|
||||||
@ -684,7 +689,7 @@ func (p *PriorityQueue) PendingPods() []*v1.Pod {
|
|||||||
for _, pInfo := range p.podBackoffQ.List() {
|
for _, pInfo := range p.podBackoffQ.List() {
|
||||||
result = append(result, pInfo.(*framework.QueuedPodInfo).Pod)
|
result = append(result, pInfo.(*framework.QueuedPodInfo).Pod)
|
||||||
}
|
}
|
||||||
for _, pInfo := range p.unschedulableQ.podInfoMap {
|
for _, pInfo := range p.unschedulablePods.podInfoMap {
|
||||||
result = append(result, pInfo.Pod)
|
result = append(result, pInfo.Pod)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@ -775,9 +780,9 @@ func updatePod(oldPodInfo interface{}, newPod *v1.Pod) *framework.QueuedPodInfo
|
|||||||
return pInfo
|
return pInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnschedulablePodsMap holds pods that cannot be scheduled. This data structure
|
// UnschedulablePods holds pods that cannot be scheduled. This data structure
|
||||||
// is used to implement unschedulableQ.
|
// is used to implement unschedulablePods.
|
||||||
type UnschedulablePodsMap struct {
|
type UnschedulablePods struct {
|
||||||
// podInfoMap is a map key by a pod's full-name and the value is a pointer to the QueuedPodInfo.
|
// podInfoMap is a map key by a pod's full-name and the value is a pointer to the QueuedPodInfo.
|
||||||
podInfoMap map[string]*framework.QueuedPodInfo
|
podInfoMap map[string]*framework.QueuedPodInfo
|
||||||
keyFunc func(*v1.Pod) string
|
keyFunc func(*v1.Pod) string
|
||||||
@ -787,7 +792,7 @@ type UnschedulablePodsMap struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add adds a pod to the unschedulable podInfoMap.
|
// Add adds a pod to the unschedulable podInfoMap.
|
||||||
func (u *UnschedulablePodsMap) addOrUpdate(pInfo *framework.QueuedPodInfo) {
|
func (u *UnschedulablePods) addOrUpdate(pInfo *framework.QueuedPodInfo) {
|
||||||
podID := u.keyFunc(pInfo.Pod)
|
podID := u.keyFunc(pInfo.Pod)
|
||||||
if _, exists := u.podInfoMap[podID]; !exists && u.metricRecorder != nil {
|
if _, exists := u.podInfoMap[podID]; !exists && u.metricRecorder != nil {
|
||||||
u.metricRecorder.Inc()
|
u.metricRecorder.Inc()
|
||||||
@ -796,7 +801,7 @@ func (u *UnschedulablePodsMap) addOrUpdate(pInfo *framework.QueuedPodInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete deletes a pod from the unschedulable podInfoMap.
|
// Delete deletes a pod from the unschedulable podInfoMap.
|
||||||
func (u *UnschedulablePodsMap) delete(pod *v1.Pod) {
|
func (u *UnschedulablePods) delete(pod *v1.Pod) {
|
||||||
podID := u.keyFunc(pod)
|
podID := u.keyFunc(pod)
|
||||||
if _, exists := u.podInfoMap[podID]; exists && u.metricRecorder != nil {
|
if _, exists := u.podInfoMap[podID]; exists && u.metricRecorder != nil {
|
||||||
u.metricRecorder.Dec()
|
u.metricRecorder.Dec()
|
||||||
@ -806,7 +811,7 @@ func (u *UnschedulablePodsMap) delete(pod *v1.Pod) {
|
|||||||
|
|
||||||
// Get returns the QueuedPodInfo if a pod with the same key as the key of the given "pod"
|
// Get returns the QueuedPodInfo if a pod with the same key as the key of the given "pod"
|
||||||
// is found in the map. It returns nil otherwise.
|
// is found in the map. It returns nil otherwise.
|
||||||
func (u *UnschedulablePodsMap) get(pod *v1.Pod) *framework.QueuedPodInfo {
|
func (u *UnschedulablePods) get(pod *v1.Pod) *framework.QueuedPodInfo {
|
||||||
podKey := u.keyFunc(pod)
|
podKey := u.keyFunc(pod)
|
||||||
if pInfo, exists := u.podInfoMap[podKey]; exists {
|
if pInfo, exists := u.podInfoMap[podKey]; exists {
|
||||||
return pInfo
|
return pInfo
|
||||||
@ -815,16 +820,16 @@ func (u *UnschedulablePodsMap) get(pod *v1.Pod) *framework.QueuedPodInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clear removes all the entries from the unschedulable podInfoMap.
|
// Clear removes all the entries from the unschedulable podInfoMap.
|
||||||
func (u *UnschedulablePodsMap) clear() {
|
func (u *UnschedulablePods) clear() {
|
||||||
u.podInfoMap = make(map[string]*framework.QueuedPodInfo)
|
u.podInfoMap = make(map[string]*framework.QueuedPodInfo)
|
||||||
if u.metricRecorder != nil {
|
if u.metricRecorder != nil {
|
||||||
u.metricRecorder.Clear()
|
u.metricRecorder.Clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// newUnschedulablePodsMap initializes a new object of UnschedulablePodsMap.
|
// newUnschedulablePods initializes a new object of UnschedulablePods.
|
||||||
func newUnschedulablePodsMap(metricRecorder metrics.MetricRecorder) *UnschedulablePodsMap {
|
func newUnschedulablePods(metricRecorder metrics.MetricRecorder) *UnschedulablePods {
|
||||||
return &UnschedulablePodsMap{
|
return &UnschedulablePods{
|
||||||
podInfoMap: make(map[string]*framework.QueuedPodInfo),
|
podInfoMap: make(map[string]*framework.QueuedPodInfo),
|
||||||
keyFunc: util.GetPodFullName,
|
keyFunc: util.GetPodFullName,
|
||||||
metricRecorder: metricRecorder,
|
metricRecorder: metricRecorder,
|
||||||
@ -840,7 +845,7 @@ type nominator struct {
|
|||||||
podLister listersv1.PodLister
|
podLister listersv1.PodLister
|
||||||
// nominatedPods is a map keyed by a node name and the value is a list of
|
// nominatedPods is a map keyed by a node name and the value is a list of
|
||||||
// pods which are nominated to run on the node. These are pods which can be in
|
// pods which are nominated to run on the node. These are pods which can be in
|
||||||
// the activeQ or unschedulableQ.
|
// the activeQ or unschedulablePods.
|
||||||
nominatedPods map[string][]*framework.PodInfo
|
nominatedPods map[string][]*framework.PodInfo
|
||||||
// nominatedPodToNode is map keyed by a Pod UID to the node name where it is
|
// nominatedPodToNode is map keyed by a Pod UID to the node name where it is
|
||||||
// nominated.
|
// nominated.
|
||||||
|
@ -122,7 +122,7 @@ var highPriorityPodInfo, highPriNominatedPodInfo, medPriorityPodInfo, unschedula
|
|||||||
})
|
})
|
||||||
|
|
||||||
func getUnschedulablePod(p *PriorityQueue, pod *v1.Pod) *v1.Pod {
|
func getUnschedulablePod(p *PriorityQueue, pod *v1.Pod) *v1.Pod {
|
||||||
pInfo := p.unschedulableQ.get(pod)
|
pInfo := p.unschedulablePods.get(pod)
|
||||||
if pInfo != nil {
|
if pInfo != nil {
|
||||||
return pInfo.Pod
|
return pInfo.Pod
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ func TestPriorityQueue_AddUnschedulableIfNotPresent(t *testing.T) {
|
|||||||
t.Errorf("Expected nomindatePods to have one element: %v", q.PodNominator)
|
t.Errorf("Expected nomindatePods to have one element: %v", q.PodNominator)
|
||||||
}
|
}
|
||||||
if getUnschedulablePod(q, unschedulablePodInfo.Pod) != unschedulablePodInfo.Pod {
|
if getUnschedulablePod(q, unschedulablePodInfo.Pod) != unschedulablePodInfo.Pod {
|
||||||
t.Errorf("Pod %v was not found in the unschedulableQ.", unschedulablePodInfo.Pod.Name)
|
t.Errorf("Pod %v was not found in the unschedulablePods.", unschedulablePodInfo.Pod.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,8 +344,8 @@ func TestPriorityQueue_Update(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// Updating a pod that is already in activeQ, should not change it.
|
// Updating a pod that is already in activeQ, should not change it.
|
||||||
q.Update(unschedulablePodInfo.Pod, unschedulablePodInfo.Pod)
|
q.Update(unschedulablePodInfo.Pod, unschedulablePodInfo.Pod)
|
||||||
if len(q.unschedulableQ.podInfoMap) != 0 {
|
if len(q.unschedulablePods.podInfoMap) != 0 {
|
||||||
t.Error("Expected unschedulableQ to be empty.")
|
t.Error("Expected unschedulablePods to be empty.")
|
||||||
}
|
}
|
||||||
if _, exists, _ := q.activeQ.Get(newQueuedPodInfoForLookup(unschedulablePodInfo.Pod)); !exists {
|
if _, exists, _ := q.activeQ.Get(newQueuedPodInfoForLookup(unschedulablePodInfo.Pod)); !exists {
|
||||||
t.Errorf("Expected: %v to be added to activeQ.", unschedulablePodInfo.Pod.Name)
|
t.Errorf("Expected: %v to be added to activeQ.", unschedulablePodInfo.Pod.Name)
|
||||||
@ -370,8 +370,8 @@ func TestPriorityQueue_Update(t *testing.T) {
|
|||||||
// updating a pod which is in unschedulable queue, and it is still backing off,
|
// updating a pod which is in unschedulable queue, and it is still backing off,
|
||||||
// we will move it to backoff queue
|
// we will move it to backoff queue
|
||||||
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(medPriorityPodInfo.Pod), q.SchedulingCycle())
|
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(medPriorityPodInfo.Pod), q.SchedulingCycle())
|
||||||
if len(q.unschedulableQ.podInfoMap) != 1 {
|
if len(q.unschedulablePods.podInfoMap) != 1 {
|
||||||
t.Error("Expected unschedulableQ to be 1.")
|
t.Error("Expected unschedulablePods to be 1.")
|
||||||
}
|
}
|
||||||
updatedPod := medPriorityPodInfo.Pod.DeepCopy()
|
updatedPod := medPriorityPodInfo.Pod.DeepCopy()
|
||||||
updatedPod.Annotations["foo"] = "test"
|
updatedPod.Annotations["foo"] = "test"
|
||||||
@ -385,12 +385,12 @@ func TestPriorityQueue_Update(t *testing.T) {
|
|||||||
// updating a pod which is in unschedulable queue, and it is not backing off,
|
// updating a pod which is in unschedulable queue, and it is not backing off,
|
||||||
// we will move it to active queue
|
// we will move it to active queue
|
||||||
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(medPriorityPodInfo.Pod), q.SchedulingCycle())
|
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(medPriorityPodInfo.Pod), q.SchedulingCycle())
|
||||||
if len(q.unschedulableQ.podInfoMap) != 1 {
|
if len(q.unschedulablePods.podInfoMap) != 1 {
|
||||||
t.Error("Expected unschedulableQ to be 1.")
|
t.Error("Expected unschedulablePods to be 1.")
|
||||||
}
|
}
|
||||||
updatedPod = medPriorityPodInfo.Pod.DeepCopy()
|
updatedPod = medPriorityPodInfo.Pod.DeepCopy()
|
||||||
updatedPod.Annotations["foo"] = "test1"
|
updatedPod.Annotations["foo"] = "test1"
|
||||||
// Move clock by podInitialBackoffDuration, so that pods in the unschedulableQ would pass the backing off,
|
// Move clock by podInitialBackoffDuration, so that pods in the unschedulablePods would pass the backing off,
|
||||||
// and the pods will be moved into activeQ.
|
// and the pods will be moved into activeQ.
|
||||||
c.Step(q.podInitialBackoffDuration)
|
c.Step(q.podInitialBackoffDuration)
|
||||||
q.Update(medPriorityPodInfo.Pod, updatedPod)
|
q.Update(medPriorityPodInfo.Pod, updatedPod)
|
||||||
@ -429,7 +429,7 @@ func TestPriorityQueue_Delete(t *testing.T) {
|
|||||||
func TestPriorityQueue_Activate(t *testing.T) {
|
func TestPriorityQueue_Activate(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
qPodInfoInUnschedulableQ []*framework.QueuedPodInfo
|
qPodInfoInUnschedulablePods []*framework.QueuedPodInfo
|
||||||
qPodInfoInPodBackoffQ []*framework.QueuedPodInfo
|
qPodInfoInPodBackoffQ []*framework.QueuedPodInfo
|
||||||
qPodInfoInActiveQ []*framework.QueuedPodInfo
|
qPodInfoInActiveQ []*framework.QueuedPodInfo
|
||||||
qPodInfoToActivate *framework.QueuedPodInfo
|
qPodInfoToActivate *framework.QueuedPodInfo
|
||||||
@ -442,13 +442,13 @@ func TestPriorityQueue_Activate(t *testing.T) {
|
|||||||
want: []*framework.QueuedPodInfo{{PodInfo: highPriNominatedPodInfo}}, // 1 already actived
|
want: []*framework.QueuedPodInfo{{PodInfo: highPriNominatedPodInfo}}, // 1 already actived
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "pod not in unschedulableQ/podBackoffQ",
|
name: "pod not in unschedulablePods/podBackoffQ",
|
||||||
qPodInfoToActivate: &framework.QueuedPodInfo{PodInfo: highPriNominatedPodInfo},
|
qPodInfoToActivate: &framework.QueuedPodInfo{PodInfo: highPriNominatedPodInfo},
|
||||||
want: []*framework.QueuedPodInfo{},
|
want: []*framework.QueuedPodInfo{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "pod in unschedulableQ",
|
name: "pod in unschedulablePods",
|
||||||
qPodInfoInUnschedulableQ: []*framework.QueuedPodInfo{{PodInfo: highPriNominatedPodInfo}},
|
qPodInfoInUnschedulablePods: []*framework.QueuedPodInfo{{PodInfo: highPriNominatedPodInfo}},
|
||||||
qPodInfoToActivate: &framework.QueuedPodInfo{PodInfo: highPriNominatedPodInfo},
|
qPodInfoToActivate: &framework.QueuedPodInfo{PodInfo: highPriNominatedPodInfo},
|
||||||
want: []*framework.QueuedPodInfo{{PodInfo: highPriNominatedPodInfo}},
|
want: []*framework.QueuedPodInfo{{PodInfo: highPriNominatedPodInfo}},
|
||||||
},
|
},
|
||||||
@ -467,13 +467,13 @@ func TestPriorityQueue_Activate(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
q := NewTestQueueWithObjects(ctx, newDefaultQueueSort(), objs)
|
q := NewTestQueueWithObjects(ctx, newDefaultQueueSort(), objs)
|
||||||
|
|
||||||
// Prepare activeQ/unschedulableQ/podBackoffQ according to the table
|
// Prepare activeQ/unschedulablePods/podBackoffQ according to the table
|
||||||
for _, qPodInfo := range tt.qPodInfoInActiveQ {
|
for _, qPodInfo := range tt.qPodInfoInActiveQ {
|
||||||
q.activeQ.Add(qPodInfo)
|
q.activeQ.Add(qPodInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, qPodInfo := range tt.qPodInfoInUnschedulableQ {
|
for _, qPodInfo := range tt.qPodInfoInUnschedulablePods {
|
||||||
q.unschedulableQ.addOrUpdate(qPodInfo)
|
q.unschedulablePods.addOrUpdate(qPodInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, qPodInfo := range tt.qPodInfoInPodBackoffQ {
|
for _, qPodInfo := range tt.qPodInfoInPodBackoffQ {
|
||||||
@ -550,8 +550,8 @@ func BenchmarkMoveAllToActiveOrBackoffQueue(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
for _, podsInUnschedulableQ := range []int{1000, 5000} {
|
for _, podsInUnschedulablePods := range []int{1000, 5000} {
|
||||||
b.Run(fmt.Sprintf("%v-%v", tt.name, podsInUnschedulableQ), func(b *testing.B) {
|
b.Run(fmt.Sprintf("%v-%v", tt.name, podsInUnschedulablePods), func(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
c := testingclock.NewFakeClock(time.Now())
|
c := testingclock.NewFakeClock(time.Now())
|
||||||
@ -574,8 +574,8 @@ func BenchmarkMoveAllToActiveOrBackoffQueue(b *testing.B) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
q := NewTestQueue(ctx, newDefaultQueueSort(), WithClock(c), WithClusterEventMap(m))
|
q := NewTestQueue(ctx, newDefaultQueueSort(), WithClock(c), WithClusterEventMap(m))
|
||||||
|
|
||||||
// Init pods in unschedulableQ.
|
// Init pods in unschedulablePods.
|
||||||
for j := 0; j < podsInUnschedulableQ; j++ {
|
for j := 0; j < podsInUnschedulablePods; j++ {
|
||||||
p := podTemplates[j%len(podTemplates)].DeepCopy()
|
p := podTemplates[j%len(podTemplates)].DeepCopy()
|
||||||
p.Name, p.UID = fmt.Sprintf("%v-%v", p.Name, j), types.UID(fmt.Sprintf("%v-%v", p.UID, j))
|
p.Name, p.UID = fmt.Sprintf("%v-%v", p.Name, j), types.UID(fmt.Sprintf("%v-%v", p.UID, j))
|
||||||
var podInfo *framework.QueuedPodInfo
|
var podInfo *framework.QueuedPodInfo
|
||||||
@ -652,11 +652,11 @@ func TestPriorityQueue_MoveAllToActiveOrBackoffQueue(t *testing.T) {
|
|||||||
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(highPriorityPodInfo.Pod, "fooPlugin"), q.SchedulingCycle())
|
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(highPriorityPodInfo.Pod, "fooPlugin"), q.SchedulingCycle())
|
||||||
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(hpp1), q.SchedulingCycle())
|
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(hpp1), q.SchedulingCycle())
|
||||||
for _, pod := range []*v1.Pod{unschedulablePodInfo.Pod, highPriorityPodInfo.Pod, hpp1, hpp2} {
|
for _, pod := range []*v1.Pod{unschedulablePodInfo.Pod, highPriorityPodInfo.Pod, hpp1, hpp2} {
|
||||||
if q.unschedulableQ.get(pod) == nil {
|
if q.unschedulablePods.get(pod) == nil {
|
||||||
t.Errorf("Expected %v in the unschedulableQ", pod.Name)
|
t.Errorf("Expected %v in the unschedulablePods", pod.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Move clock by podInitialBackoffDuration, so that pods in the unschedulableQ would pass the backing off,
|
// Move clock by podInitialBackoffDuration, so that pods in the unschedulablePods would pass the backing off,
|
||||||
// and the pods will be moved into activeQ.
|
// and the pods will be moved into activeQ.
|
||||||
c.Step(q.podInitialBackoffDuration)
|
c.Step(q.podInitialBackoffDuration)
|
||||||
q.MoveAllToActiveOrBackoffQueue(NodeAdd, nil)
|
q.MoveAllToActiveOrBackoffQueue(NodeAdd, nil)
|
||||||
@ -670,7 +670,7 @@ func TestPriorityQueue_MoveAllToActiveOrBackoffQueue(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestPriorityQueue_AssignedPodAdded tests AssignedPodAdded. It checks that
|
// TestPriorityQueue_AssignedPodAdded tests AssignedPodAdded. It checks that
|
||||||
// when a pod with pod affinity is in unschedulableQ and another pod with a
|
// when a pod with pod affinity is in unschedulablePods and another pod with a
|
||||||
// matching label is added, the unschedulable pod is moved to activeQ.
|
// matching label is added, the unschedulable pod is moved to activeQ.
|
||||||
func TestPriorityQueue_AssignedPodAdded(t *testing.T) {
|
func TestPriorityQueue_AssignedPodAdded(t *testing.T) {
|
||||||
affinityPod := unschedulablePodInfo.Pod.DeepCopy()
|
affinityPod := unschedulablePodInfo.Pod.DeepCopy()
|
||||||
@ -711,7 +711,7 @@ func TestPriorityQueue_AssignedPodAdded(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
q := NewTestQueue(ctx, newDefaultQueueSort(), WithClock(c), WithClusterEventMap(m))
|
q := NewTestQueue(ctx, newDefaultQueueSort(), WithClock(c), WithClusterEventMap(m))
|
||||||
q.Add(medPriorityPodInfo.Pod)
|
q.Add(medPriorityPodInfo.Pod)
|
||||||
// Add a couple of pods to the unschedulableQ.
|
// Add a couple of pods to the unschedulablePods.
|
||||||
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(unschedulablePodInfo.Pod, "fakePlugin"), q.SchedulingCycle())
|
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(unschedulablePodInfo.Pod, "fakePlugin"), q.SchedulingCycle())
|
||||||
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(affinityPod, "fakePlugin"), q.SchedulingCycle())
|
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(affinityPod, "fakePlugin"), q.SchedulingCycle())
|
||||||
|
|
||||||
@ -721,14 +721,14 @@ func TestPriorityQueue_AssignedPodAdded(t *testing.T) {
|
|||||||
// affinityPod. So, affinityPod should go to activeQ.
|
// affinityPod. So, affinityPod should go to activeQ.
|
||||||
q.AssignedPodAdded(&labelPod)
|
q.AssignedPodAdded(&labelPod)
|
||||||
if getUnschedulablePod(q, affinityPod) != nil {
|
if getUnschedulablePod(q, affinityPod) != nil {
|
||||||
t.Error("affinityPod is still in the unschedulableQ.")
|
t.Error("affinityPod is still in the unschedulablePods.")
|
||||||
}
|
}
|
||||||
if _, exists, _ := q.activeQ.Get(newQueuedPodInfoForLookup(affinityPod)); !exists {
|
if _, exists, _ := q.activeQ.Get(newQueuedPodInfoForLookup(affinityPod)); !exists {
|
||||||
t.Error("affinityPod is not moved to activeQ.")
|
t.Error("affinityPod is not moved to activeQ.")
|
||||||
}
|
}
|
||||||
// Check that the other pod is still in the unschedulableQ.
|
// Check that the other pod is still in the unschedulablePods.
|
||||||
if getUnschedulablePod(q, unschedulablePodInfo.Pod) == nil {
|
if getUnschedulablePod(q, unschedulablePodInfo.Pod) == nil {
|
||||||
t.Error("unschedulablePodInfo is not in the unschedulableQ.")
|
t.Error("unschedulablePodInfo is not in the unschedulablePods.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1045,7 +1045,7 @@ func TestUnschedulablePodsMap(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
upm := newUnschedulablePodsMap(nil)
|
upm := newUnschedulablePods(nil)
|
||||||
for _, p := range test.podsToAdd {
|
for _, p := range test.podsToAdd {
|
||||||
upm.addOrUpdate(newQueuedPodInfoForLookup(p))
|
upm.addOrUpdate(newQueuedPodInfoForLookup(p))
|
||||||
}
|
}
|
||||||
@ -1319,9 +1319,9 @@ func TestHighPriorityBackoff(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestHighPriorityFlushUnschedulableQLeftover tests that pods will be moved to
|
// TestHighPriorityFlushUnschedulablePodsLeftover tests that pods will be moved to
|
||||||
// activeQ after one minutes if it is in unschedulableQ
|
// activeQ after one minutes if it is in unschedulablePods.
|
||||||
func TestHighPriorityFlushUnschedulableQLeftover(t *testing.T) {
|
func TestHighPriorityFlushUnschedulablePodsLeftover(t *testing.T) {
|
||||||
c := testingclock.NewFakeClock(time.Now())
|
c := testingclock.NewFakeClock(time.Now())
|
||||||
m := map[framework.ClusterEvent]sets.String{
|
m := map[framework.ClusterEvent]sets.String{
|
||||||
NodeAdd: sets.NewString("fakePlugin"),
|
NodeAdd: sets.NewString("fakePlugin"),
|
||||||
@ -1374,8 +1374,8 @@ func TestHighPriorityFlushUnschedulableQLeftover(t *testing.T) {
|
|||||||
|
|
||||||
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(&highPod, "fakePlugin"), q.SchedulingCycle())
|
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(&highPod, "fakePlugin"), q.SchedulingCycle())
|
||||||
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(&midPod, "fakePlugin"), q.SchedulingCycle())
|
q.AddUnschedulableIfNotPresent(q.newQueuedPodInfo(&midPod, "fakePlugin"), q.SchedulingCycle())
|
||||||
c.Step(DefaultPodMaxUnschedulableQDuration + time.Second)
|
c.Step(DefaultPodMaxInUnschedulablePodsDuration + time.Second)
|
||||||
q.flushUnschedulableQLeftover()
|
q.flushUnschedulablePodsLeftover()
|
||||||
|
|
||||||
if p, err := q.Pop(); err != nil || p.Pod != &highPod {
|
if p, err := q.Pop(); err != nil || p.Pod != &highPod {
|
||||||
t.Errorf("Expected: %v after Pop, but got: %v", highPriorityPodInfo.Pod.Name, p.Pod.Name)
|
t.Errorf("Expected: %v after Pop, but got: %v", highPriorityPodInfo.Pod.Name, p.Pod.Name)
|
||||||
@ -1385,7 +1385,7 @@ func TestHighPriorityFlushUnschedulableQLeftover(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPriorityQueue_initPodMaxUnschedulableQDuration(t *testing.T) {
|
func TestPriorityQueue_initPodMaxInUnschedulablePodsDuration(t *testing.T) {
|
||||||
pod1 := &v1.Pod{
|
pod1 := &v1.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "test-pod-1",
|
Name: "test-pod-1",
|
||||||
@ -1420,27 +1420,27 @@ func TestPriorityQueue_initPodMaxUnschedulableQDuration(t *testing.T) {
|
|||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
podMaxUnschedulableQDuration time.Duration
|
podMaxInUnschedulablePodsDuration time.Duration
|
||||||
operations []operation
|
operations []operation
|
||||||
operands []*framework.QueuedPodInfo
|
operands []*framework.QueuedPodInfo
|
||||||
expected []*framework.QueuedPodInfo
|
expected []*framework.QueuedPodInfo
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "New priority queue by the default value of podMaxUnschedulableQDuration",
|
name: "New priority queue by the default value of podMaxInUnschedulablePodsDuration",
|
||||||
operations: []operation{
|
operations: []operation{
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
flushUnschedulerQ,
|
flushUnschedulerQ,
|
||||||
},
|
},
|
||||||
operands: []*framework.QueuedPodInfo{pInfo1, pInfo2, nil},
|
operands: []*framework.QueuedPodInfo{pInfo1, pInfo2, nil},
|
||||||
expected: []*framework.QueuedPodInfo{pInfo2, pInfo1},
|
expected: []*framework.QueuedPodInfo{pInfo2, pInfo1},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "New priority queue by user-defined value of podMaxUnschedulableQDuration",
|
name: "New priority queue by user-defined value of podMaxInUnschedulablePodsDuration",
|
||||||
podMaxUnschedulableQDuration: 30 * time.Second,
|
podMaxInUnschedulablePodsDuration: 30 * time.Second,
|
||||||
operations: []operation{
|
operations: []operation{
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
flushUnschedulerQ,
|
flushUnschedulerQ,
|
||||||
},
|
},
|
||||||
operands: []*framework.QueuedPodInfo{pInfo1, pInfo2, nil},
|
operands: []*framework.QueuedPodInfo{pInfo1, pInfo2, nil},
|
||||||
@ -1453,10 +1453,10 @@ func TestPriorityQueue_initPodMaxUnschedulableQDuration(t *testing.T) {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
var queue *PriorityQueue
|
var queue *PriorityQueue
|
||||||
if test.podMaxUnschedulableQDuration > 0 {
|
if test.podMaxInUnschedulablePodsDuration > 0 {
|
||||||
queue = NewTestQueue(ctx, newDefaultQueueSort(),
|
queue = NewTestQueue(ctx, newDefaultQueueSort(),
|
||||||
WithClock(testingclock.NewFakeClock(timestamp)),
|
WithClock(testingclock.NewFakeClock(timestamp)),
|
||||||
WithPodMaxUnschedulableQDuration(test.podMaxUnschedulableQDuration))
|
WithPodMaxInUnschedulablePodsDuration(test.podMaxInUnschedulablePodsDuration))
|
||||||
} else {
|
} else {
|
||||||
queue = NewTestQueue(ctx, newDefaultQueueSort(),
|
queue = NewTestQueue(ctx, newDefaultQueueSort(),
|
||||||
WithClock(testingclock.NewFakeClock(timestamp)))
|
WithClock(testingclock.NewFakeClock(timestamp)))
|
||||||
@ -1494,7 +1494,7 @@ var (
|
|||||||
add = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
add = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
||||||
queue.Add(pInfo.Pod)
|
queue.Add(pInfo.Pod)
|
||||||
}
|
}
|
||||||
addUnschedulablePodBackToUnschedulableQ = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
addUnschedulablePodBackToUnschedulablePods = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
||||||
queue.AddUnschedulableIfNotPresent(pInfo, 0)
|
queue.AddUnschedulableIfNotPresent(pInfo, 0)
|
||||||
}
|
}
|
||||||
addUnschedulablePodBackToBackoffQ = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
addUnschedulablePodBackToBackoffQ = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
||||||
@ -1506,7 +1506,7 @@ var (
|
|||||||
updatePodActiveQ = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
updatePodActiveQ = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
||||||
queue.activeQ.Update(pInfo)
|
queue.activeQ.Update(pInfo)
|
||||||
}
|
}
|
||||||
addPodUnschedulableQ = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
addPodUnschedulablePods = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
||||||
// Update pod condition to unschedulable.
|
// Update pod condition to unschedulable.
|
||||||
podutil.UpdatePodCondition(&pInfo.Pod.Status, &v1.PodCondition{
|
podutil.UpdatePodCondition(&pInfo.Pod.Status, &v1.PodCondition{
|
||||||
Type: v1.PodScheduled,
|
Type: v1.PodScheduled,
|
||||||
@ -1514,7 +1514,7 @@ var (
|
|||||||
Reason: v1.PodReasonUnschedulable,
|
Reason: v1.PodReasonUnschedulable,
|
||||||
Message: "fake scheduling failure",
|
Message: "fake scheduling failure",
|
||||||
})
|
})
|
||||||
queue.unschedulableQ.addOrUpdate(pInfo)
|
queue.unschedulablePods.addOrUpdate(pInfo)
|
||||||
}
|
}
|
||||||
addPodBackoffQ = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
addPodBackoffQ = func(queue *PriorityQueue, pInfo *framework.QueuedPodInfo) {
|
||||||
queue.podBackoffQ.Add(pInfo)
|
queue.podBackoffQ.Add(pInfo)
|
||||||
@ -1530,8 +1530,8 @@ var (
|
|||||||
queue.clock.(*testingclock.FakeClock).Step(2 * time.Second)
|
queue.clock.(*testingclock.FakeClock).Step(2 * time.Second)
|
||||||
}
|
}
|
||||||
flushUnschedulerQ = func(queue *PriorityQueue, _ *framework.QueuedPodInfo) {
|
flushUnschedulerQ = func(queue *PriorityQueue, _ *framework.QueuedPodInfo) {
|
||||||
queue.clock.(*testingclock.FakeClock).Step(queue.podMaxUnschedulableQDuration)
|
queue.clock.(*testingclock.FakeClock).Step(queue.podMaxInUnschedulablePodsDuration)
|
||||||
queue.flushUnschedulableQLeftover()
|
queue.flushUnschedulablePodsLeftover()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1594,10 +1594,10 @@ func TestPodTimestamp(t *testing.T) {
|
|||||||
expected: []*framework.QueuedPodInfo{pInfo1, pInfo2},
|
expected: []*framework.QueuedPodInfo{pInfo1, pInfo2},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add two pod to unschedulableQ then move them to activeQ and sort them by the timestamp",
|
name: "add two pod to unschedulablePods then move them to activeQ and sort them by the timestamp",
|
||||||
operations: []operation{
|
operations: []operation{
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
moveClockForward,
|
moveClockForward,
|
||||||
moveAllToActiveOrBackoffQ,
|
moveAllToActiveOrBackoffQ,
|
||||||
},
|
},
|
||||||
@ -1666,10 +1666,10 @@ func TestPendingPodsMetric(t *testing.T) {
|
|||||||
wants string
|
wants string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "add pods to activeQ and unschedulableQ",
|
name: "add pods to activeQ and unschedulablePods",
|
||||||
operations: []operation{
|
operations: []operation{
|
||||||
addPodActiveQ,
|
addPodActiveQ,
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
},
|
},
|
||||||
operands: [][]*framework.QueuedPodInfo{
|
operands: [][]*framework.QueuedPodInfo{
|
||||||
pInfos[:30],
|
pInfos[:30],
|
||||||
@ -1677,7 +1677,7 @@ func TestPendingPodsMetric(t *testing.T) {
|
|||||||
},
|
},
|
||||||
metricsName: "scheduler_pending_pods",
|
metricsName: "scheduler_pending_pods",
|
||||||
wants: `
|
wants: `
|
||||||
# HELP scheduler_pending_pods [STABLE] Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulableQ.
|
# HELP scheduler_pending_pods [STABLE] Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulablePods.
|
||||||
# TYPE scheduler_pending_pods gauge
|
# TYPE scheduler_pending_pods gauge
|
||||||
scheduler_pending_pods{queue="active"} 30
|
scheduler_pending_pods{queue="active"} 30
|
||||||
scheduler_pending_pods{queue="backoff"} 0
|
scheduler_pending_pods{queue="backoff"} 0
|
||||||
@ -1689,7 +1689,7 @@ scheduler_pending_pods{queue="unschedulable"} 20
|
|||||||
operations: []operation{
|
operations: []operation{
|
||||||
addPodActiveQ,
|
addPodActiveQ,
|
||||||
addPodBackoffQ,
|
addPodBackoffQ,
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
},
|
},
|
||||||
operands: [][]*framework.QueuedPodInfo{
|
operands: [][]*framework.QueuedPodInfo{
|
||||||
pInfos[:15],
|
pInfos[:15],
|
||||||
@ -1698,7 +1698,7 @@ scheduler_pending_pods{queue="unschedulable"} 20
|
|||||||
},
|
},
|
||||||
metricsName: "scheduler_pending_pods",
|
metricsName: "scheduler_pending_pods",
|
||||||
wants: `
|
wants: `
|
||||||
# HELP scheduler_pending_pods [STABLE] Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulableQ.
|
# HELP scheduler_pending_pods [STABLE] Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulablePods.
|
||||||
# TYPE scheduler_pending_pods gauge
|
# TYPE scheduler_pending_pods gauge
|
||||||
scheduler_pending_pods{queue="active"} 15
|
scheduler_pending_pods{queue="active"} 15
|
||||||
scheduler_pending_pods{queue="backoff"} 25
|
scheduler_pending_pods{queue="backoff"} 25
|
||||||
@ -1706,9 +1706,9 @@ scheduler_pending_pods{queue="unschedulable"} 10
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add pods to unschedulableQ and then move all to activeQ",
|
name: "add pods to unschedulablePods and then move all to activeQ",
|
||||||
operations: []operation{
|
operations: []operation{
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
moveClockForward,
|
moveClockForward,
|
||||||
moveAllToActiveOrBackoffQ,
|
moveAllToActiveOrBackoffQ,
|
||||||
},
|
},
|
||||||
@ -1719,7 +1719,7 @@ scheduler_pending_pods{queue="unschedulable"} 10
|
|||||||
},
|
},
|
||||||
metricsName: "scheduler_pending_pods",
|
metricsName: "scheduler_pending_pods",
|
||||||
wants: `
|
wants: `
|
||||||
# HELP scheduler_pending_pods [STABLE] Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulableQ.
|
# HELP scheduler_pending_pods [STABLE] Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulablePods.
|
||||||
# TYPE scheduler_pending_pods gauge
|
# TYPE scheduler_pending_pods gauge
|
||||||
scheduler_pending_pods{queue="active"} 50
|
scheduler_pending_pods{queue="active"} 50
|
||||||
scheduler_pending_pods{queue="backoff"} 0
|
scheduler_pending_pods{queue="backoff"} 0
|
||||||
@ -1727,11 +1727,11 @@ scheduler_pending_pods{queue="unschedulable"} 0
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "make some pods subject to backoff, add pods to unschedulableQ, and then move all to activeQ",
|
name: "make some pods subject to backoff, add pods to unschedulablePods, and then move all to activeQ",
|
||||||
operations: []operation{
|
operations: []operation{
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
moveClockForward,
|
moveClockForward,
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
moveAllToActiveOrBackoffQ,
|
moveAllToActiveOrBackoffQ,
|
||||||
},
|
},
|
||||||
operands: [][]*framework.QueuedPodInfo{
|
operands: [][]*framework.QueuedPodInfo{
|
||||||
@ -1742,7 +1742,7 @@ scheduler_pending_pods{queue="unschedulable"} 0
|
|||||||
},
|
},
|
||||||
metricsName: "scheduler_pending_pods",
|
metricsName: "scheduler_pending_pods",
|
||||||
wants: `
|
wants: `
|
||||||
# HELP scheduler_pending_pods [STABLE] Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulableQ.
|
# HELP scheduler_pending_pods [STABLE] Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulablePods.
|
||||||
# TYPE scheduler_pending_pods gauge
|
# TYPE scheduler_pending_pods gauge
|
||||||
scheduler_pending_pods{queue="active"} 30
|
scheduler_pending_pods{queue="active"} 30
|
||||||
scheduler_pending_pods{queue="backoff"} 20
|
scheduler_pending_pods{queue="backoff"} 20
|
||||||
@ -1750,9 +1750,9 @@ scheduler_pending_pods{queue="unschedulable"} 0
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "make some pods subject to backoff, add pods to unschedulableQ/activeQ, move all to activeQ, and finally flush backoffQ",
|
name: "make some pods subject to backoff, add pods to unschedulablePods/activeQ, move all to activeQ, and finally flush backoffQ",
|
||||||
operations: []operation{
|
operations: []operation{
|
||||||
addPodUnschedulableQ,
|
addPodUnschedulablePods,
|
||||||
addPodActiveQ,
|
addPodActiveQ,
|
||||||
moveAllToActiveOrBackoffQ,
|
moveAllToActiveOrBackoffQ,
|
||||||
flushBackoffQ,
|
flushBackoffQ,
|
||||||
@ -1765,7 +1765,7 @@ scheduler_pending_pods{queue="unschedulable"} 0
|
|||||||
},
|
},
|
||||||
metricsName: "scheduler_pending_pods",
|
metricsName: "scheduler_pending_pods",
|
||||||
wants: `
|
wants: `
|
||||||
# HELP scheduler_pending_pods [STABLE] Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulableQ.
|
# HELP scheduler_pending_pods [STABLE] Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulablePods.
|
||||||
# TYPE scheduler_pending_pods gauge
|
# TYPE scheduler_pending_pods gauge
|
||||||
scheduler_pending_pods{queue="active"} 50
|
scheduler_pending_pods{queue="active"} 50
|
||||||
scheduler_pending_pods{queue="backoff"} 0
|
scheduler_pending_pods{queue="backoff"} 0
|
||||||
@ -1825,7 +1825,7 @@ func TestPerPodSchedulingMetrics(t *testing.T) {
|
|||||||
checkPerPodSchedulingMetrics("Attempt once", t, pInfo, 1, timestamp)
|
checkPerPodSchedulingMetrics("Attempt once", t, pInfo, 1, timestamp)
|
||||||
|
|
||||||
// Case 2: A pod is created and scheduled after 2 attempts. The queue operations are
|
// Case 2: A pod is created and scheduled after 2 attempts. The queue operations are
|
||||||
// Add -> Pop -> AddUnschedulableIfNotPresent -> flushUnschedulableQLeftover -> Pop.
|
// Add -> Pop -> AddUnschedulableIfNotPresent -> flushUnschedulablePodsLeftover -> Pop.
|
||||||
c = testingclock.NewFakeClock(timestamp)
|
c = testingclock.NewFakeClock(timestamp)
|
||||||
queue = NewTestQueue(ctx, newDefaultQueueSort(), WithClock(c))
|
queue = NewTestQueue(ctx, newDefaultQueueSort(), WithClock(c))
|
||||||
queue.Add(pod)
|
queue.Add(pod)
|
||||||
@ -1834,10 +1834,10 @@ func TestPerPodSchedulingMetrics(t *testing.T) {
|
|||||||
t.Fatalf("Failed to pop a pod %v", err)
|
t.Fatalf("Failed to pop a pod %v", err)
|
||||||
}
|
}
|
||||||
queue.AddUnschedulableIfNotPresent(pInfo, 1)
|
queue.AddUnschedulableIfNotPresent(pInfo, 1)
|
||||||
// Override clock to exceed the DefaultPodMaxUnschedulableQDuration so that unschedulable pods
|
// Override clock to exceed the DefaultPodMaxInUnschedulablePodsDuration so that unschedulable pods
|
||||||
// will be moved to activeQ
|
// will be moved to activeQ
|
||||||
c.SetTime(timestamp.Add(DefaultPodMaxUnschedulableQDuration + 1))
|
c.SetTime(timestamp.Add(DefaultPodMaxInUnschedulablePodsDuration + 1))
|
||||||
queue.flushUnschedulableQLeftover()
|
queue.flushUnschedulablePodsLeftover()
|
||||||
pInfo, err = queue.Pop()
|
pInfo, err = queue.Pop()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to pop a pod %v", err)
|
t.Fatalf("Failed to pop a pod %v", err)
|
||||||
@ -1845,7 +1845,7 @@ func TestPerPodSchedulingMetrics(t *testing.T) {
|
|||||||
checkPerPodSchedulingMetrics("Attempt twice", t, pInfo, 2, timestamp)
|
checkPerPodSchedulingMetrics("Attempt twice", t, pInfo, 2, timestamp)
|
||||||
|
|
||||||
// Case 3: Similar to case 2, but before the second pop, call update, the queue operations are
|
// Case 3: Similar to case 2, but before the second pop, call update, the queue operations are
|
||||||
// Add -> Pop -> AddUnschedulableIfNotPresent -> flushUnschedulableQLeftover -> Update -> Pop.
|
// Add -> Pop -> AddUnschedulableIfNotPresent -> flushUnschedulablePodsLeftover -> Update -> Pop.
|
||||||
c = testingclock.NewFakeClock(timestamp)
|
c = testingclock.NewFakeClock(timestamp)
|
||||||
queue = NewTestQueue(ctx, newDefaultQueueSort(), WithClock(c))
|
queue = NewTestQueue(ctx, newDefaultQueueSort(), WithClock(c))
|
||||||
queue.Add(pod)
|
queue.Add(pod)
|
||||||
@ -1854,10 +1854,10 @@ func TestPerPodSchedulingMetrics(t *testing.T) {
|
|||||||
t.Fatalf("Failed to pop a pod %v", err)
|
t.Fatalf("Failed to pop a pod %v", err)
|
||||||
}
|
}
|
||||||
queue.AddUnschedulableIfNotPresent(pInfo, 1)
|
queue.AddUnschedulableIfNotPresent(pInfo, 1)
|
||||||
// Override clock to exceed the DefaultPodMaxUnschedulableQDuration so that unschedulable pods
|
// Override clock to exceed the DefaultPodMaxInUnschedulablePodsDuration so that unschedulable pods
|
||||||
// will be moved to activeQ
|
// will be moved to activeQ
|
||||||
c.SetTime(timestamp.Add(DefaultPodMaxUnschedulableQDuration + 1))
|
c.SetTime(timestamp.Add(DefaultPodMaxInUnschedulablePodsDuration + 1))
|
||||||
queue.flushUnschedulableQLeftover()
|
queue.flushUnschedulablePodsLeftover()
|
||||||
newPod := pod.DeepCopy()
|
newPod := pod.DeepCopy()
|
||||||
newPod.Generation = 1
|
newPod.Generation = 1
|
||||||
queue.Update(pod, newPod)
|
queue.Update(pod, newPod)
|
||||||
@ -1900,18 +1900,18 @@ func TestIncomingPodsMetrics(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add pods to unschedulableQ",
|
name: "add pods to unschedulablePods",
|
||||||
operations: []operation{
|
operations: []operation{
|
||||||
addUnschedulablePodBackToUnschedulableQ,
|
addUnschedulablePodBackToUnschedulablePods,
|
||||||
},
|
},
|
||||||
want: `
|
want: `
|
||||||
scheduler_queue_incoming_pods_total{event="ScheduleAttemptFailure",queue="unschedulable"} 3
|
scheduler_queue_incoming_pods_total{event="ScheduleAttemptFailure",queue="unschedulable"} 3
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add pods to unschedulableQ and then move all to backoffQ",
|
name: "add pods to unschedulablePods and then move all to backoffQ",
|
||||||
operations: []operation{
|
operations: []operation{
|
||||||
addUnschedulablePodBackToUnschedulableQ,
|
addUnschedulablePodBackToUnschedulablePods,
|
||||||
moveAllToActiveOrBackoffQ,
|
moveAllToActiveOrBackoffQ,
|
||||||
},
|
},
|
||||||
want: ` scheduler_queue_incoming_pods_total{event="ScheduleAttemptFailure",queue="unschedulable"} 3
|
want: ` scheduler_queue_incoming_pods_total{event="ScheduleAttemptFailure",queue="unschedulable"} 3
|
||||||
@ -1919,9 +1919,9 @@ func TestIncomingPodsMetrics(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add pods to unschedulableQ and then move all to activeQ",
|
name: "add pods to unschedulablePods and then move all to activeQ",
|
||||||
operations: []operation{
|
operations: []operation{
|
||||||
addUnschedulablePodBackToUnschedulableQ,
|
addUnschedulablePodBackToUnschedulablePods,
|
||||||
moveClockForward,
|
moveClockForward,
|
||||||
moveAllToActiveOrBackoffQ,
|
moveAllToActiveOrBackoffQ,
|
||||||
},
|
},
|
||||||
|
@ -93,7 +93,7 @@ var (
|
|||||||
&metrics.GaugeOpts{
|
&metrics.GaugeOpts{
|
||||||
Subsystem: SchedulerSubsystem,
|
Subsystem: SchedulerSubsystem,
|
||||||
Name: "pending_pods",
|
Name: "pending_pods",
|
||||||
Help: "Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulableQ.",
|
Help: "Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulablePods.",
|
||||||
StabilityLevel: metrics.STABLE,
|
StabilityLevel: metrics.STABLE,
|
||||||
}, []string{"queue"})
|
}, []string{"queue"})
|
||||||
SchedulerGoroutines = metrics.NewGaugeVec(
|
SchedulerGoroutines = metrics.NewGaugeVec(
|
||||||
|
@ -129,7 +129,7 @@ type schedulerOptions struct {
|
|||||||
percentageOfNodesToScore int32
|
percentageOfNodesToScore int32
|
||||||
podInitialBackoffSeconds int64
|
podInitialBackoffSeconds int64
|
||||||
podMaxBackoffSeconds int64
|
podMaxBackoffSeconds int64
|
||||||
podMaxUnschedulableQDuration time.Duration
|
podMaxInUnschedulablePodsDuration time.Duration
|
||||||
// Contains out-of-tree plugins to be merged with the in-tree registry.
|
// Contains out-of-tree plugins to be merged with the in-tree registry.
|
||||||
frameworkOutOfTreeRegistry frameworkruntime.Registry
|
frameworkOutOfTreeRegistry frameworkruntime.Registry
|
||||||
profiles []schedulerapi.KubeSchedulerProfile
|
profiles []schedulerapi.KubeSchedulerProfile
|
||||||
@ -215,10 +215,10 @@ func WithPodMaxBackoffSeconds(podMaxBackoffSeconds int64) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithPodMaxUnschedulableQDuration sets PodMaxUnschedulableQDuration for PriorityQueue.
|
// WithPodMaxInUnschedulablePodsDuration sets podMaxInUnschedulablePodsDuration for PriorityQueue.
|
||||||
func WithPodMaxUnschedulableQDuration(duration time.Duration) Option {
|
func WithPodMaxInUnschedulablePodsDuration(duration time.Duration) Option {
|
||||||
return func(o *schedulerOptions) {
|
return func(o *schedulerOptions) {
|
||||||
o.podMaxUnschedulableQDuration = duration
|
o.podMaxInUnschedulablePodsDuration = duration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ var defaultSchedulerOptions = schedulerOptions{
|
|||||||
percentageOfNodesToScore: schedulerapi.DefaultPercentageOfNodesToScore,
|
percentageOfNodesToScore: schedulerapi.DefaultPercentageOfNodesToScore,
|
||||||
podInitialBackoffSeconds: int64(internalqueue.DefaultPodInitialBackoffDuration.Seconds()),
|
podInitialBackoffSeconds: int64(internalqueue.DefaultPodInitialBackoffDuration.Seconds()),
|
||||||
podMaxBackoffSeconds: int64(internalqueue.DefaultPodMaxBackoffDuration.Seconds()),
|
podMaxBackoffSeconds: int64(internalqueue.DefaultPodMaxBackoffDuration.Seconds()),
|
||||||
podMaxUnschedulableQDuration: internalqueue.DefaultPodMaxUnschedulableQDuration,
|
podMaxInUnschedulablePodsDuration: internalqueue.DefaultPodMaxInUnschedulablePodsDuration,
|
||||||
parallelism: int32(parallelize.DefaultParallelism),
|
parallelism: int32(parallelize.DefaultParallelism),
|
||||||
// Ideally we would statically set the default profile here, but we can't because
|
// Ideally we would statically set the default profile here, but we can't because
|
||||||
// creating the default profile may require testing feature gates, which may get
|
// creating the default profile may require testing feature gates, which may get
|
||||||
@ -355,7 +355,7 @@ func New(client clientset.Interface,
|
|||||||
internalqueue.WithPodMaxBackoffDuration(time.Duration(options.podMaxBackoffSeconds)*time.Second),
|
internalqueue.WithPodMaxBackoffDuration(time.Duration(options.podMaxBackoffSeconds)*time.Second),
|
||||||
internalqueue.WithPodNominator(nominator),
|
internalqueue.WithPodNominator(nominator),
|
||||||
internalqueue.WithClusterEventMap(clusterEventMap),
|
internalqueue.WithClusterEventMap(clusterEventMap),
|
||||||
internalqueue.WithPodMaxUnschedulableQDuration(options.podMaxUnschedulableQDuration),
|
internalqueue.WithPodMaxInUnschedulablePodsDuration(options.podMaxInUnschedulablePodsDuration),
|
||||||
)
|
)
|
||||||
|
|
||||||
schedulerCache := internalcache.New(durationToExpireAssumedPod, stopEverything)
|
schedulerCache := internalcache.New(durationToExpireAssumedPod, stopEverything)
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
subsystem: scheduler
|
subsystem: scheduler
|
||||||
help: Number of pending pods, by the queue type. 'active' means number of pods in
|
help: Number of pending pods, by the queue type. 'active' means number of pods in
|
||||||
activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number
|
activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number
|
||||||
of pods in unschedulableQ.
|
of pods in unschedulablePods.
|
||||||
type: Gauge
|
type: Gauge
|
||||||
stabilityLevel: STABLE
|
stabilityLevel: STABLE
|
||||||
labels:
|
labels:
|
||||||
|
@ -107,12 +107,12 @@ func TestCoreResourceEnqueue(t *testing.T) {
|
|||||||
testCtx.Scheduler.Error(podInfo, fitError)
|
testCtx.Scheduler.Error(podInfo, fitError)
|
||||||
|
|
||||||
// Scheduling cycle is incremented by one after NextPod() is called, so
|
// Scheduling cycle is incremented by one after NextPod() is called, so
|
||||||
// pass a number larger than i to move Pod to unschedulableQ.
|
// pass a number larger than i to move Pod to unschedulablePods.
|
||||||
testCtx.Scheduler.SchedulingQueue.AddUnschedulableIfNotPresent(podInfo, int64(i+10))
|
testCtx.Scheduler.SchedulingQueue.AddUnschedulableIfNotPresent(podInfo, int64(i+10))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger a NodeTaintChange event.
|
// Trigger a NodeTaintChange event.
|
||||||
// We expect this event to trigger moving the test Pod from unschedulableQ to activeQ.
|
// We expect this event to trigger moving the test Pod from unschedulablePods to activeQ.
|
||||||
node.Spec.Taints = nil
|
node.Spec.Taints = nil
|
||||||
if _, err := cs.CoreV1().Nodes().Update(ctx, node, metav1.UpdateOptions{}); err != nil {
|
if _, err := cs.CoreV1().Nodes().Update(ctx, node, metav1.UpdateOptions{}); err != nil {
|
||||||
t.Fatalf("Failed to remove taints off the node: %v", err)
|
t.Fatalf("Failed to remove taints off the node: %v", err)
|
||||||
@ -285,11 +285,11 @@ func TestCustomResourceEnqueue(t *testing.T) {
|
|||||||
testCtx.Scheduler.Error(podInfo, fitError)
|
testCtx.Scheduler.Error(podInfo, fitError)
|
||||||
|
|
||||||
// Scheduling cycle is incremented from 0 to 1 after NextPod() is called, so
|
// Scheduling cycle is incremented from 0 to 1 after NextPod() is called, so
|
||||||
// pass a number larger than 1 to move Pod to unschedulableQ.
|
// pass a number larger than 1 to move Pod to unschedulablePods.
|
||||||
testCtx.Scheduler.SchedulingQueue.AddUnschedulableIfNotPresent(podInfo, 10)
|
testCtx.Scheduler.SchedulingQueue.AddUnschedulableIfNotPresent(podInfo, 10)
|
||||||
|
|
||||||
// Trigger a Custom Resource event.
|
// Trigger a Custom Resource event.
|
||||||
// We expect this event to trigger moving the test Pod from unschedulableQ to activeQ.
|
// We expect this event to trigger moving the test Pod from unschedulablePods to activeQ.
|
||||||
crdGVR := schema.GroupVersionResource{Group: fooCRD.Spec.Group, Version: fooCRD.Spec.Versions[0].Name, Resource: "foos"}
|
crdGVR := schema.GroupVersionResource{Group: fooCRD.Spec.Group, Version: fooCRD.Spec.Versions[0].Name, Resource: "foos"}
|
||||||
crClient := dynamicClient.Resource(crdGVR).Namespace(ns)
|
crClient := dynamicClient.Resource(crdGVR).Namespace(ns)
|
||||||
if _, err := crClient.Create(ctx, &unstructured.Unstructured{
|
if _, err := crClient.Create(ctx, &unstructured.Unstructured{
|
||||||
|
Loading…
Reference in New Issue
Block a user