mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-26 15:43:56 +00:00
Previously, when a Pod residing in the 'unschedulablePods' queue was updated and subsequently rejected by PreEnqueue plugins (returning 'Wait'), the logic in 'moveToActiveQ' would return early because the Pod was already present in the queue. This caused the 'scheduler_gated_pods_total' metric to fail to increment, leading to metric inconsistencies (and potentially negative values upon Pod deletion). This change adds a check to detect the transition from Ungated to Gated. If detected, the Pod is removed and re-added to the queue to ensure metrics are correctly swapped (Unschedulable-- and Gated++). Added regression test 'TestSchedulingQueueMetrics_UngatedToGated' to verify the fix. Signed-off-by: Vlad Shkrabkov <vshkrabkov@google.com>