Skip to content

waitForSSHReady cannot report failure: it returns nothing, so a 120s timeout renders as "✅ Waiting for SSH" and the launch proceeds to SSH-dependent steps #740

Closed

Description

@scttfrdmn

Root cause of the stall reproduced in the 2026-10-07 follow-up, and the keystone
of a four-defect chain. Found by a SIGQUIT goroutine dump on a watchdog.

The defect

cmd/launch_posthook.go:294:

func waitForSSHReady(ctx context.Context, host string, timeout time.Duration) {

No return value. The timeout path and the success path are the same
statement:

if err == nil { _ = conn.Close(); return }   // reachable
select {
case <-ctx.Done():  return                   // NOT reachable — identical return
case <-ticker.C:
}

And the call site (cmd/launch_single.go:890-894) completes the progress step
unconditionally:

prog.Start("Waiting for SSH")
if waitForSSH && result.PublicIP != "" {
    waitForSSHReady(ctx, result.PublicIP, 2*time.Minute)   // cannot fail
}
prog.Complete("Waiting for SSH")                           // always ✅

Observed in the repro:

02:50:49   ✅ Getting public IP (71ms)
02:52:49   ✅ Waiting for SSH (120.0s)      <- exactly the timeout, still a ✅

120.0s to the tenth of a second is the deadline path's signature. SSH was never
reachable, and the launch reported that step as done.

Why this is the keystone, not a display bug

The launch then proceeds to steps that depend on SSH working. In the same
dump, the process is parked in registerDNS → exec.Cmd.CombinedOutput →
ssh, i.e. SSHing to the host it had just failed to reach, for minutes. See the
companion issue on registerDNS's retry budget.

Nothing in between catches it either: verifySporedReady (:905) passed, because
it uses SSM, which was working. So the instance had booted, spored was up, and
the one thing that was broken — the SSH path — was the one signal thrown away.

The full chain from the repro:

  1. launch auto-detects a region by TCP latency, ignoring AWS_REGION, the config default, and whether the instance type is even offered there #732 — AWS_REGION=us-east-1 ignored, instance auto-placed in us-west-1.
  2. SSH never became reachable there (cause still open; the default VPC in
    us-west-1 has an IGW and MapPublicIpOnLaunch=true on all subnets, so it is
    not a missing internet path, and the caller-IP SSH ingress rule left in
    that region matches the controller's current public IP correctly — so neither
    of the two obvious explanations holds).
  3. This issue — the failure is unobservable and unreported.
  4. verifySporedReady succeeds over SSM, so no other gate notices.
  5. registerDNS SSHes to the unreachable host under a 4-minute retry deadline.
  6. 24 of 32 progress step names are unregistered, so spawn's longest operations print nothing while they run #739 — "Registering DNS" and "Verifying spored agent" are unregistered
    progress step names, so steps 4–5 print nothing while they run.

Worst case: 2 min (this) + ~4 min (DNS retry) ≈ 6 minutes of silence after a
successful RunInstances
, which is the originally-reported "hang". The reporter
killed the demo run at ~5m14s.

Suggested fix

  1. Return an error. waitForSSHReady should return error, non-nil on
    deadline, and the caller should prog.Error("Waiting for SSH", err) rather
    than Complete.
  2. Use it as a gate. An unreachable SSH port means the SSH-dependent steps
    cannot work. registerDNS should be skipped with a clear message (the code
    already has exactly this logic for --wait-for-ssh=false at
    cmd/launch_single.go:937 — "we cannot and should not register a record
    pointing at an instance whose reachability is unconfirmed"
    . That reasoning
    applies identically here; it just isn't reachable, because the failure is
    invisible).
  3. Say what to do. SSM worked, so the instance is usable:
    SSH did not become reachable in 2m0s — the instance is up and reachable over SSM; check the security group's port-22 ingress, or use 'spawn connect' which falls back to SSM. That is a far better outcome than a ✅ followed by minutes
    of silence.
  4. Keep it non-fatal. The instance is fine and spored is enforcing its
    lifecycle; this should degrade the launch, not fail it.

The guard result.PublicIP != "" is also worth a look — a launch with no public
IP skips the wait entirely and still prints ✅, which is the same false claim by a
different route.

Environment: spawn v0.123.0, c8g.xlarge, us-west-1 (auto-selected), AL2023.
Reproduced first try.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions