Skip to content

fix: DNS registration is skippable and no longer burns 4 min on a dead endpoint (#548, #549) - #552

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/548-549-dns-registration
Aug 20, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/548-549-dns-registration

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

Fixes #548 and #549 together — both touch the same DNS-registration guard in cmd/launch_single.go, so they're combined to avoid a merge conflict between separate PRs.

#549 — no way to skip DNS registration; dns.enabled was dead code

  • dns.enabled in ~/.spawn/config.yaml was parsed but never consulted anywhere.
  • Worse: it was a plain bool, so any config file present but silent on dns: unmarshaled Enabled to false and silently disabled DNS registration for every named launch.
  • Added --no-dns flag.
  • DNSConfig.Enabled is now a tri-state (*bool): nil = "unspecified, use the default (enabled)"; a config file that never mentions dns: no longer disables anything.
  • Precedence: CLI flag (--no-dns) > config file (dns.enabled) > default (enabled) — matches the existing flag-over-config convention used by --ttl etc.
  • --no-dns is distinct from --wait-for-ssh=false (e2e Tier 2 harness can't run ~22 launches in parallel — waitForRunning times out, SSH ControlMaster contention #56): it skips only DNS registration, not the SSH-readiness wait.

#548 — DNS registration burned a hard 4-minute retry on a permanently-unresolvable hostname

  • registerDNS's retry loop treated curl exit 6 (couldn't resolve host) as always-transient — correct for the guest's resolver not being populated yet at early boot (observed up to ~90s), wrong for a stale/placeholder dns.api_endpoint or an account never wired for spore.host DNS (the expected case per the code's own comment).
  • Added a controller-side preflight (preflightDNSEndpoint) that resolves the endpoint hostname before entering the SSH retry loop. Only a definitive NXDOMAIN (net.DNSError.IsNotFound) short-circuits to the non-fatal warning immediately; a transient lookup failure (timeout, temporarily unreachable resolver) falls through to the existing retry loop unchanged.
  • This is approach (a) from the issue (controller-side resolve, no guest-side script changes) — simpler than (b) and sufficient to close the cost gap.
  • Measured cost eliminated: ~$7.60/3-host fleet launch, recurring on every relaunch against a permanently-dead endpoint.

How they interact

--no-dns (#549) takes the #548 cost to zero for callers who use it. #548's own fix bounds the cost for everyone else (stale config, unaware of the flag, or genuinely wants DNS but the account isn't wired for it).

Tests

  • pkg/config/config_test.go: tri-state IsEnabled() behavior, and LoadDNSConfig precedence — no config file (defaults enabled), config file present but silent on dns: (still enabled — the exact No way to skip DNS registration on a launch, and dns.enabled is parsed but never read #549 bug report), dns.enabled: false alone, --no-dns overriding dns.enabled: true, both agreeing on disabled, and the plain "nothing set" default-proceeds case.
  • cmd/launch_posthook_test.go:
    • TestShouldAttemptDNSRegistration — the launch-flow guard's full decision table (no DNS name, SSH not confirmed, config disabled, config enabled/default, nil config).
    • TestEndpointHostname / TestIsPermanentResolutionFailure — unit coverage for the URL-parsing and NXDOMAIN-classification helpers.
    • TestPreflightDNSEndpoint_PermanentlyUnresolvable_ShortCircuits — permanent failure returns immediately (asserts wall-clock < 1s).
    • TestPreflightDNSEndpoint_TransientFailure_DoesNotShortCircuit — the critical regression guard: timeout/temporary/generic errors must NOT be classified as permanent, or the genuinely-transient early-boot case would break.
    • TestRegisterDNS_PermanentlyUnresolvable_SkipsSSHEntirely — end-to-end: registerDNS itself returns near-instantly (< 2s) for a permanently-unresolvable endpoint, proving the SSH retry loop (which sleeps 5s between attempts) was never entered.
  • Fail-without/pass-with verified by hand: reverting each new production file compiles the corresponding test file into a compile error (the new tests reference symbols — boolPtr, IsEnabled, endpointHostname, resolveHost, preflightDNSEndpoint, isPermanentResolutionFailure — that only exist with the fix), confirming the tests exercise the new code paths rather than trivially passing either way.
  • go test -race ./cmd/... ./pkg/config/... passes clean.

Process

Test plan

  • go build ./...
  • go vet ./...
  • go test -race ./cmd/... ./pkg/config/...
  • make check
  • make gen-docs && make check-docs (docs-gen committed)
  • go build/go mod tidy -diff in all lambda/*/ submodules — clean
  • Manually confirmed spawn launch --help shows the new --no-dns flag with its help text

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_single.go 0.00% 3 Missing ⚠️
cmd/launch_posthook.go 92.59% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

… dead endpoint (#548, #549)

present-but-silent-on-dns: unmarshaled it to false, silently disabling DNS
registration. Add --no-dns, make DNSConfig.Enabled a tri-state (*bool) so
"unspecified" != "explicitly false", and wire the guard in launch_single.go
to consult it (CLI flag beats config file, matching --ttl's precedence).

as always-transient, so a permanently-unresolvable dns.api_endpoint (stale
config, or an account not wired for spore.host DNS — the expected case)
burned the full 4-minute deadline on every launch (~$7.60/3-host fleet).
Add a controller-side preflight resolve check before the SSH retry loop;
only a definitive NXDOMAIN (net.DNSError.IsNotFound) short-circuits, so the
genuinely-transient early-boot resolver case (up to ~90s) still retries as
before.
@scttfrdmn
scttfrdmn force-pushed the fix/548-549-dns-registration branch from c94a0f5 to d4767be Compare August 20, 2026 20:06
@scttfrdmn
scttfrdmn merged commit 47cf16e into main Aug 20, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/548-549-dns-registration branch August 20, 2026 20:16
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.

DNS registration burns a hard 4 minutes per launch on curl exit 6, which is permanent whenever the endpoint hostname does not exist

1 participant