Skip to content

fix(pod): show SchedulingGated for pods held by scheduling gates - #4313

Merged
uozalp merged 3 commits into
derailed:masterfrom
kevin9327:fix/pod-phase-scheduling-gated
Oct 22, 2026
Merged

uozalp merged 3 commits into
derailed:masterfrom
kevin9327:fix/pod-phase-scheduling-gated

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

Problem

A pod held back by spec.schedulingGates shows Pending in the k9s pod view. kubectl, and k9s's own PodStatus helper, show SchedulingGated. That's the only hint that the pod is waiting on a gate rather than on the scheduler. kubectl's printPod does:

for _, condition := range pod.Status.Conditions {
    if condition.Type == api.PodScheduled && condition.Reason == api.PodReasonSchedulingGated {
        reason = api.PodReasonSchedulingGated
    }
}

Pod.Phase, which renders the STATUS column, skipped this check.

Fix

Pod.Phase now applies the same PodScheduled / SchedulingGated condition check as PodStatus.

Tests

New TestCheckPhase case scheduling-gated. It returned Pending before the fix and returns SchedulingGated now. go test ./internal/render/... ./internal/view/... passes.

AI-assisted: I directed the investigation and reviewed and verified the change myself.

Comment thread internal/render/pod.go
Comment on lines +474 to +476
if c.Type == v1.PodScheduled && c.Reason == v1.PodReasonSchedulingGated {
status = v1.PodReasonSchedulingGated
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Consider adding a break after setting the status, since we've found the condition we're looking for and don't need to continue iterating.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, added the break in c6e8399. go test ./internal/render/ still passes.

Comment thread internal/render/pod.go Resolved

@uozalp uozalp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@uozalp
uozalp merged commit c023c9d into derailed:master Oct 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants