Repository navigation
Description
The time cost of the stall reproduced in the 2026-10-07 follow-up. #740 is why it
is entered at all; this is why it lasts minutes.
Where the launch was parked
From a SIGQUIT dump taken by a watchdog 39s into the stall:
goroutine 1 [syscall]:
os/exec.(*Cmd).CombinedOutput
github.com/spore-host/spawn/cmd.registerDNS cmd/launch_posthook.go:251
github.com/spore-host/spawn/cmd.launchWithProgress cmd/launch_single.go:930
github.com/spore-host/spawn/cmd.runLaunch cmd/launch_single.go:379
Line 251 is output, err = cmd.CombinedOutput(), and the child is ssh — DNS
registration is performed by SSHing into the instance and running a script that
curls the DNS API.
Three compounding problems
deadline := time.Now().Add(4 * time.Minute)
for {
cmd := exec.Command("ssh", sshArgs...) // <- not CommandContext
output, err = cmd.CombinedOutput()
transient := err != nil || bytes.Contains(output, []byte("curl exit 6")) || …
if !transient || time.Now().After(deadline) { break }
time.Sleep(5 * time.Second)
}- It is on the critical path.
spawn launchdoes not return until this
finishes. The result is explicitly non-fatal — a failure prints a warning and
the launch succeeds — so the user waits minutes for an outcome that does not
change anything. - The 4-minute deadline is checked only between attempts. A single
long attempt runs past it unbounded.ConnectTimeout=10caps the TCP connect
only, not the session: an ssh that connects and then hangs (post-handshake, or
a wedged remote script) is not bounded by anything, becauseexec.Commandhas
no context.exec.CommandContextwith the loop's deadline would fix the
unbounded case for free. - The retry predicate treats every error as transient.
transient := err != nil || …— soPermission denied (publickey)and
Connection refusedboth retry for the full 4 minutes, even though neither
will resolve. The comment explains the intent well (early-boot
authorized_keysand resolver races are genuinely session-level and
genuinely need a fresh session) but the predicate does not discriminate
between those and a host that is simply unreachable.
With a reachable-but-not-ready host that is correct behaviour. With an
unreachable host — #740's case, where SSH readiness already failed and was
discarded — it is ~16 futile attempts over 4 minutes. Combined with #740's 2
minutes, that is the originally-reported "5+ minute hang": the demo run was killed
at ~5m14s, and this repro was killed by the watchdog 39s in, mid-loop, which is
why the dump shows a single exec in flight rather than a retry.
And #739 means none of it prints: "Registering DNS" is not a registered
progress step name, so prog.Start/Complete/Error for it are silent no-ops.
Suggested fix
- Gate on SSH readiness (needs 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). If the port-22 wait failed, skip this
with a message. The code already does exactly this for--wait-for-ssh=false
atcmd/launch_single.go:937; the same branch should cover "we waited and it
never came up". exec.CommandContextwith the loop's deadline, so no single attempt can
outlive the budget.- Narrow the retry predicate to the conditions the comment actually
describes —Permission denied,curl exit 6/7/28— and stop retrying on
Connection refused/Connection timed out/No route to host, which are
reachability failures that a fresh session cannot fix. - Consider taking it off the critical path entirely. It is best-effort and
its own comment says so. Registering asynchronously, or deferring to the
spawn dns registerthe code already suggests on the skip path, would remove
minutes from the worst case.
Possible shared fix with #733
#733 is that NewAgent performs a DNS registration write, making spawn status
non-read-only. This is the other caller of the same registration path, from the
other side. Both would be addressed by making DNS registration explicitly
asynchronous and best-effort with a deadline, rather than something each caller
blocks on. Worth checking whether one change covers both before fixing them
separately — the reporter raised this and I think it holds, though the two call
paths differ (this one shells out to ssh; #733's is in-process in spored).
Environment: spawn v0.123.0. Reproduced first try on c8g.xlarge in us-west-1
(auto-selected — #732). Instance self-terminated as designed; nothing leaked.
Activity
fix(launch): make the SSH-readiness result reportable, and gate DNS o…
fix(progress): append unknown steps instead of dropping them silently
fix(progress): append unknown steps instead of dropping them silently (…