diff --git a/pkg/scheduler/internal/queue/events.go b/pkg/scheduler/internal/queue/events.go index f8b8cb29c97..3aa5e6f2488 100644 --- a/pkg/scheduler/internal/queue/events.go +++ b/pkg/scheduler/internal/queue/events.go @@ -30,6 +30,8 @@ const ( // ForceActivate is the event when a pod is moved from unschedulablePods/backoffQ // to activeQ. Usually it's triggered by plugin implementations. ForceActivate = "ForceActivate" + // PodUpdate is the event when a pod is updated + PodUpdate = "PodUpdate" ) var ( diff --git a/pkg/scheduler/internal/queue/scheduling_queue.go b/pkg/scheduler/internal/queue/scheduling_queue.go index a7f4ce47a3b..1c989601f28 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue.go +++ b/pkg/scheduler/internal/queue/scheduling_queue.go @@ -58,6 +58,11 @@ const ( DefaultPodMaxInUnschedulablePodsDuration time.Duration = 5 * time.Minute queueClosed = "scheduling queue is closed" + + // Scheduling queue names + activeQName = "Active" + backoffQName = "Backoff" + unschedulablePods = "Unschedulable" ) const ( @@ -313,6 +318,7 @@ func (p *PriorityQueue) Add(pod *v1.Pod) error { if err := p.podBackoffQ.Delete(pInfo); err == nil { klog.ErrorS(nil, "Error: pod is already in the podBackoff queue", "pod", klog.KObj(pod)) } + klog.V(5).InfoS("Pod moved to an internal scheduling queue", "pod", klog.KObj(pod), "event", PodAdd, "queue", activeQName) metrics.SchedulerQueueIncomingPods.WithLabelValues("active", PodAdd).Inc() p.PodNominator.AddNominatedPod(pInfo.PodInfo, nil) p.cond.Broadcast() @@ -417,9 +423,11 @@ func (p *PriorityQueue) AddUnschedulableIfNotPresent(pInfo *framework.QueuedPodI if err := p.podBackoffQ.Add(pInfo); err != nil { return fmt.Errorf("error adding pod %v to the backoff queue: %v", klog.KObj(pod), err) } + klog.V(5).InfoS("Pod moved to an internal scheduling queue", "pod", klog.KObj(pod), "event", ScheduleAttemptFailure, "queue", backoffQName) metrics.SchedulerQueueIncomingPods.WithLabelValues("backoff", ScheduleAttemptFailure).Inc() } else { p.unschedulablePods.addOrUpdate(pInfo) + klog.V(5).InfoS("Pod moved to an internal scheduling queue", "pod", klog.KObj(pod), "event", ScheduleAttemptFailure, "queue", unschedulablePods) metrics.SchedulerQueueIncomingPods.WithLabelValues("unschedulable", ScheduleAttemptFailure).Inc() } @@ -449,6 +457,7 @@ func (p *PriorityQueue) flushBackoffQCompleted() { break } p.activeQ.Add(rawPodInfo) + klog.V(5).InfoS("Pod moved to an internal scheduling queue", "pod", klog.KObj(pod), "event", BackoffComplete, "queue", activeQName) metrics.SchedulerQueueIncomingPods.WithLabelValues("active", BackoffComplete).Inc() activated = true } @@ -553,11 +562,13 @@ func (p *PriorityQueue) Update(oldPod, newPod *v1.Pod) error { return err } p.unschedulablePods.delete(usPodInfo.Pod) + klog.V(5).InfoS("Pod moved to an internal scheduling queue", "pod", klog.KObj(pInfo.Pod), "event", PodUpdate, "queue", backoffQName) } else { if err := p.activeQ.Add(pInfo); err != nil { return err } p.unschedulablePods.delete(usPodInfo.Pod) + klog.V(5).InfoS("Pod moved to an internal scheduling queue", "pod", klog.KObj(pInfo.Pod), "event", BackoffComplete, "queue", activeQName) p.cond.Broadcast() } } else { @@ -573,6 +584,7 @@ func (p *PriorityQueue) Update(oldPod, newPod *v1.Pod) error { return err } p.PodNominator.AddNominatedPod(pInfo.PodInfo, nil) + klog.V(5).InfoS("Pod moved to an internal scheduling queue", "pod", klog.KObj(pInfo.Pod), "event", PodUpdate, "queue", activeQName) p.cond.Broadcast() return nil } @@ -639,6 +651,7 @@ func (p *PriorityQueue) movePodsToActiveOrBackoffQueue(podInfoList []*framework. if err := p.podBackoffQ.Add(pInfo); err != nil { klog.ErrorS(err, "Error adding pod to the backoff queue", "pod", klog.KObj(pod)) } else { + klog.V(5).InfoS("Pod moved to an internal scheduling queue", "pod", klog.KObj(pInfo.Pod), "event", event, "queue", backoffQName) metrics.SchedulerQueueIncomingPods.WithLabelValues("backoff", event.Label).Inc() p.unschedulablePods.delete(pod) } @@ -646,6 +659,7 @@ func (p *PriorityQueue) movePodsToActiveOrBackoffQueue(podInfoList []*framework. if err := p.activeQ.Add(pInfo); err != nil { klog.ErrorS(err, "Error adding pod to the scheduling queue", "pod", klog.KObj(pod)) } else { + klog.V(5).InfoS("Pod moved to an internal scheduling queue", "pod", klog.KObj(pInfo.Pod), "event", event, "queue", activeQName) activated = true metrics.SchedulerQueueIncomingPods.WithLabelValues("active", event.Label).Inc() p.unschedulablePods.delete(pod)