Repository navigation
fix(launch): make the SSH-readiness result reportable, and gate DNS on it (#740, #741) - #742
Merged
Merged
Conversation
…n it Reproduced from a goroutine dump: a launch that succeeded then sat for six minutes in registerDNS -> exec -> ssh, SSHing to a host whose SSH port had already failed to answer, printing nothing. #740, the root cause: waitForSSHReady RETURNED NOTHING. The timeout path and the success path were the same statement, so the failure was not dropped — it was unrepresentable. The caller then called prog.Complete("Waiting for SSH") unconditionally, so an unreachable instance printed `✅ Waiting for SSH (120.0s)`: the timeout, to the tenth of a second, rendered as success. Nothing downstream caught it either. The next gate verifies spored over SSM, which was working — so the instance was healthy, spored was up, and the single broken thing was the single signal being discarded. - waitForSSHReady returns an error naming the host and the dial failure (refused vs timed out are different diagnoses). - The launch reports it and stays non-fatal: the instance is running and spored is enforcing TTL/idle/cost, so failing here would destroy a working spore over a connectivity problem. It points at `spawn connect`, which falls back to SSM. - It now GATES DNS registration, which registers over SSH. That skip already existed for --wait-for-ssh=false, with the reasoning in a comment — "we cannot and should not register a record pointing at an instance whose reachability is unconfirmed" — and was unreachable for the case where we DID wait and it failed. - A launch with no public IP no longer claims to have checked SSH. #741, the time cost, two fixes in the retry itself: - The four-minute budget was checked only BETWEEN attempts and the exec had no context, so one ssh that connected and then hung outlived the deadline (ConnectTimeout=10 caps only the TCP connect). The budget now binds every attempt via CommandContext, and the caller's ctx is threaded through so a Ctrl-C reaches the child. - The predicate was `err != nil`: EVERY failure counted as a transient early-boot race, so an unreachable host spent the full four minutes on ~16 attempts that could not succeed. sshRegisterRetryable now retries the races it was written for (Permission denied before cloud-init writes authorized_keys; curl exit 6/7/28 from an instance whose resolver is not up) and stops on reachability failures. An UNRECOGNISED message stays retryable, so a wording we have not seen degrades to the old behaviour rather than giving up early. Gates confirmed to fail on revert: returning nil from the timeout, and restoring `err != nil` as the predicate. The first version of the timeout test PASSED against the broken code, because it probed 127.0.0.1 and this machine runs sshd — waitForSSHReady hardcodes port 22, so "unreachable" has to be unreachable for the probe's port, not for one I picked. It now uses 203.0.113.1 (TEST-NET-3).
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #740. Closes #741.
Both halves of the stall the reporter captured with a SIGQUIT watchdog. They ship
together because #741's fix is #740's return value — the gate has nothing to
gate on until the probe can fail.
#740 — the failure was not dropped, it was unrepresentable
No return value. The timeout path and the success path were the same
returnstatement. The caller then called
prog.Complete("Waiting for SSH")unconditionally, so an unreachable instance printed:
120.0sto the tenth of a second is the deadline, rendered as success.Nothing downstream caught it either, and that is the part worth dwelling on:
the next gate verifies spored over SSM, which was working. The instance was
healthy, spored was up, and the one broken thing was the one signal being
discarded. Then the launch SSHed to that host for another four minutes.
Now the probe returns an error naming the host and the dial failure — "refused"
and "timed out" are different diagnoses and the user needs to know which. The
launch reports it and stays non-fatal: the instance is running and spored is
enforcing TTL/idle/cost, so failing here would destroy a working spore over a
connectivity problem. It points at
spawn connect, which already falls back toSSM.
The gate already existed.
--wait-for-ssh=falseskips DNS registration, withthe reasoning spelled out in its own comment — "we cannot and should not register
a record pointing at an instance whose reachability is unconfirmed". Identical
reasoning, simply unreachable for the case where we did wait and it failed. This
makes it reachable.
Also: a launch with no public IP skipped the probe and still printed ✅. Same false
claim by a different route; now it says what it skipped and why.
#741 — three compounding problems in the retry
exec.Commandhas no contextsshthat connects then hangs outlives the four-minute deadline entirely —ConnectTimeout=10caps only the TCP connecterr != nilsshRegisterRetryablenow distinguishes the races the retry was actually writtenfor —
Permission denied (publickey)before cloud-init writesauthorized_keys,and
curl exit 6/7/28from an instance whose resolver is not yet up, both ofwhich a fresh session genuinely recovers — from reachability failures, which no
fresh session can fix.
An unrecognised message stays retryable on purpose: a wording we have not seen
should degrade to the old behaviour, not cause a new class of premature give-up.
The failure mode of being too eager to retry is a slow launch; of being too eager
to stop, a broken one.
Verification
Gates confirmed to fail when reverted:
nilwaitForSSHReady returned nil for an unreachable host — the caller cannot tell this from success, which is exactly #740err != nilas the predicatesshRegisterRetryable = true, want false — a fresh session reaches the same refusing host — this is #741's four wasted minutesThe first version of the timeout test passed against the broken code. It
probed
127.0.0.1, and this machine runssshd—waitForSSHReadyhardcodesport 22, so the dial succeeded and returned nil legitimately. "Unreachable" has to
be unreachable for the probe's port, not for a port I picked. Now uses
203.0.113.1(TEST-NET-3, RFC 5737). Recorded in the test comment, because thenext person writing a port-22 test will reach for loopback too.
gofmt,go vet ./...,go test -short ./...,make check-docs, changeloggate,
semgrep scan --config=auto --error(0 findings).Not in this PR
"Registering DNS"and"Verifying spored agent"are unregisteredprogress step names, so this whole sequence prints nothing while it runs. That
is why the stall was invisible; this PR is why it was long. Separate fix.
is why its SSH path was in question at all. The first link in the chain and the
largest change.
NewAgentperforming a DNS registration write, i.e. the sameregistration path from the other side. Worth checking whether an
async-and-deadlined DNS registration covers both before fixing separately; the
call paths do differ (this one shells out to
ssh, spawn status performs a live DNS registration write (and re-runs agent init) on every invocation #733's is in-process).Why SSH was unreachable in us-west-1 remains open. Two obvious explanations are
ruled out and recorded in #740: the default VPC there has an IGW with
MapPublicIpOnLaunch=trueon every subnet, and the spawn-managed port-22 ingressrule left in that region matches the controller's current public IP exactly. It
needs a live instance there to settle, and none of these fixes depend on it.