Skip to content

fix(pod): don't report Init:N/M for a started sidecar that is not ready - #4311

Merged
uozalp merged 2 commits into
derailed:masterfrom
kevin9327:fix/pod-sidecar-started-not-ready
Oct 22, 2026
Merged

uozalp merged 2 commits into
derailed:masterfrom
kevin9327:fix/pod-sidecar-started-not-ready

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

Problem

A pod with a native sidecar (an init container with restartPolicy: Always) whose readiness probe is failing shows Init:0/1 in the STATUS column, even though the sidecar has started and the main containers are running. kubectl shows the same pod as Running.

In checkInitContainerStatus, a started restartable init container only counts as done when it is also ready. Otherwise it falls through to Init:N/M. kubectl's printPod treats a started sidecar as past initialization whether or not it is ready (readiness only affects the READY count):

case isRestartableInitContainer(initContainers[container.Name]) &&
    container.Started != nil && *container.Started:
    if container.Ready {
        readyContainers++
    }
    continue

k9s's own initContainerStatus, used by PodStatus, already skips sidecars in this case, so the two code paths also disagreed.

Fix

A started restartable init container no longer blocks the phase. Readiness is still reflected in the READY column and in the pod health check, which haven't changed.

Tests

  • New TestCheckPhase case restartable-started-not-ready: a started, not-ready sidecar plus a running, ready main container. It now gives Running; before the fix it gave Init:0/1.
  • Updated the restart case of Test_checkInitContainerStatus, which recorded the old behaviour.

go test ./internal/render/... ./internal/view/... passes.

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

@uozalp

uozalp commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

@kevin9327 One test missing: a sidecar with Started false/nil should still give Init:N/M. Can you add that case to Test_checkInitContainerStatus? Right now nothing fails if the Started check gets dropped.

Also the restart case is now the started + not ready one, maybe rename it.

@kevin9327

Copy link
Copy Markdown
Contributor Author

@uozalp Thanks, added in 8b657b1:

  • restart-not-started (Started: false) and restart-started-nil (Started unset) both expect Init:0/0. I checked that they fail if the cs.Started != nil && *cs.Started condition is dropped.
  • Renamed the old restart case to restart-started-not-ready.

go test ./internal/render/ passes.

@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.

@kevin9327 thanks for the update

@uozalp
uozalp merged commit ac1bcc6 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