Skip to content

fix(ssh): fall back to single-pod read when list omits runtime (#408) - #409

Open
digvijaygunjal wants to merge 2 commits into
runpod:mainfrom
digvijaygunjal:fix/408-ssh-info-runtime-fallback
Open

digvijaygunjal wants to merge 2 commits into
runpod:mainfrom
digvijaygunjal:fix/408-ssh-info-runtime-fallback

Conversation

@digvijaygunjal

@digvijaygunjal digvijaygunjal commented Nov 23, 2026 •

Copy link
Copy Markdown

Summary

Closes #408.

ssh info (and the deprecated ssh connect alias) derived pod readiness only from GetPods(), the /pods list endpoint. That endpoint can omit runtime for a pod that's already running and reachable, while GET /pods/{id} already reports it. internal/waitfor/pod.go already works around this for pod create --wait via its PodReader fallback; ssh info never got the same fallback, so a fully-up pod could be reported "no container reported yet" for as long as the list read lagged the single-pod one (25+ minutes in the issue).

We hit this same list/single-pod divergence ourselves, independent of the issue report: a pod running a job of ours sat reachable over SSH while ssh info reported it not ready, and separately pod list reported runtimeStatus: initializing / awaiting_container for a pod that a single-pod read already showed fully up. Same root cause, two different commands.

Fix

When the pod found via the list has no Runtime, re-read it with client.GetPodRuntime(pod.ID) before deriving state — same pattern as internal/waitfor/pod.go, applied at this call site.

Changes

  • cmd/ssh.go: add the fallback read, guarded by fresh.ID == pod.ID — the same check internal/waitfor/pod.go already applies to its version of this read, so a mismatched response is never trusted.
  • cmd/ssh_test.go: extend sshStub to optionally serve /pods/<id> with a response that diverges from the list (simulating the race); three tests — the fallback firing when the list lags, the fallback read failing (falls back to the pre-fix not-ready behavior instead of erroring), and the fallback read returning a different pod's id (ignored).

Testing

  • go build ./..., go vet ./cmd/... — clean.
  • golangci-lint run -c .golangci.yml --new-from-rev=72afce1 ./cmd/... — 0 new findings.
  • go test ./... — full suite passes.
  • go test ./cmd/... -race — passes for cmd and every other package; cmd/transfer's TestTextReceiveNeverTouchesAnExistingFile fails under -race on a vendored croc data race, reproduced identically on base commit 72afce1 with no changes checked out — pre-existing, unrelated to this diff.
  • Live API: created a pod, polled ssh info through boot. Confirmed (via a temporary debug line, not part of this diff) that GetPodRuntime fires on every poll where the list hadn't caught up yet, and that the single-pod read is what first reports the pod running. Pod deleted immediately after.
  • No new e2e/ test for the race itself: it depends on real backend timing and isn't reliably reproducible on demand in a live test. e2e/cli_test.go's existing TestCLI_PodCreateFromTemplate already calls ssh info against a live pod as a happy-path regression check, and internal/waitfor/pod.go's identical fallback (added in feat(pod,serverless): add --wait and --wait-timeout to create (CON-689) #317) has the same shape of coverage — TestCLI_PodCreateWait is also happy-path only, not a dedicated race trigger. This PR's new tests cover the race deterministically instead, via the stubbed server in cmd/ssh_test.go.

Scope

Only the single-pod path (ssh info <pod-id>, FindPodConnection). The no-arg ssh connect / ListConnections list path has the same gap but isn't part of #408 and isn't touched here.

@digvijaygunjal
digvijaygunjal force-pushed the fix/408-ssh-info-runtime-fallback branch from 9ba642b to 459f64c Compare November 23, 2026 23:45
…d#408)

`ssh info` (and the deprecated `ssh connect` alias) derived pod readiness
solely from GetPods(), the /pods list endpoint. That endpoint can omit
runtime/ssh fields for a pod that is already running and reachable, while
the single-pod GET (/pods/{id}) already reports them -- the exact gap
Client.GetPodRuntime's own doc comment describes, and the one
internal/waitfor/pod.go already re-reads around for `pod create --wait`.

ssh info never got that fallback, so a fully-up pod could be reported as
"no container reported yet (image pull, container create or boot)" for
as long as the list read lagged behind the single-pod one -- 25+ minutes
in the field per runpod#408, despite container logs showing sshd already up.

Add the same fallback `pod create --wait` already has: when the listed
pod has no runtime, re-read it via GetPodRuntime before deriving state.

Added a regression test (TestSSHInfo_FallsBackToSinglePodReadWhenListLagsRuntime)
exercising a stubbed list/get divergence, and extended the ssh test stub
to serve /pods/<id> so it can simulate that divergence.

Not yet e2e-tested against the live API per AGENTS.md's non-negotiable
rule -- opening as a draft for that reason; happy to run that pass (costs
a live pod) before this is marked ready, or if a maintainer can confirm
the fix from the unit test alone.

Fixes runpod#408
@digvijaygunjal
digvijaygunjal force-pushed the fix/408-ssh-info-runtime-fallback branch from 459f64c to 786d884 Compare November 23, 2026 23:46
@digvijaygunjal
digvijaygunjal marked this pull request as ready for review November 23, 2026 23:53
Mirror internal/waitfor/pod.go's fresh.ID == podID check on the same
fallback read in cmd/ssh.go -- the first version trusted any non-error,
non-nil GetPodRuntime response without checking it actually describes
the pod being queried.

Added two tests: the fallback read failing (confirms the command still
falls back to the pre-fix not-ready behavior instead of erroring), and
the fallback read returning a different pod's id (confirms it's ignored).
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.

v3.1.1: ssh info reports 'pod not ready: no container reported yet' for ready pods (pod get / pod logs show the container running)

1 participant