Skip to content

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

Closed

Description

@scttfrdmn

registerDNS classifies curl exit 6 (couldn't resolve host) as transient and retries it for a hard 4 minutes, on every launch, even when the endpoint hostname can never resolve. A permanently-wrong api_endpoint therefore costs 4 minutes of instance-hours per launch with a single warning line as the only symptom.

Measured on v0.101.0 (072c4b0, binary and source the same commit), launching a 3-host fleet in us-east-1.

Mechanism

cmd/launch_posthook.go:151-162:

var output []byte
deadline := time.Now().Add(4 * time.Minute)
for {
	cmd := exec.Command("ssh", sshArgs...)
	output, err = cmd.CombinedOutput()
	transient := err != nil || bytes.Contains(output, []byte("curl exit 6")) ||
		bytes.Contains(output, []byte("curl exit 7")) || bytes.Contains(output, []byte("curl exit 28"))
	if !transient || time.Now().After(deadline) {
		break
	}
	time.Sleep(5 * time.Second)
}

The comment above it (:142-150) is right about why exit 6 is retried — a fresh instance's resolver isn't populated at the time the shallow port-22 check returns, "observed past 90s". That case is real and transient.

But exit 6 is also what you get when the hostname does not exist, and the two are indistinguishable to this predicate. In the second case every one of the ~48 attempts is guaranteed to fail and the loop runs to the full deadline.

That the permanent case is normal is already acknowledged four lines from the call site — cmd/launch_single.go:893:

// Registration is expected to fail in accounts not wired for spore.host DNS.

So the retry policy is spending 4 minutes on an outcome the caller documents as expected. Same for a stale or placeholder dns.api_endpoint in ~/.spawn/config.yaml, which is how I hit it: the config-file value outranks both SSM and the compiled-in defaultAPIEndpoint (pkg/config/config.go:69-78 runs after :58-66), so one stale line silently buys 4 minutes per launch forever.

Observed

Three hosts, launched sequentially, one warning each:

⚠️  DNS registration failed (non-fatal — use the public IP or `spawn connect keel-zen4`): could not reach DNS API (curl exit 6): 000
⚠️  DNS registration failed (non-fatal — use the public IP or `spawn connect keel-zen5`): could not reach DNS API (curl exit 6): 000
⚠️  DNS registration failed (non-fatal — use the public IP or `spawn connect keel-gnr`): could not reach DNS API (curl exit 6): 000

launch_instance success timestamps were 06:27:33Z, 06:32:35Z, 06:37:35Z — 5:02 and 5:00 apart. The stages spawn times itself sum to 22.8s of that (Launching instance 2.7s + Waiting for instance 15.7s + Getting public IP 286ms + Waiting for SSH 4.1s). I am not attributing the whole 5:00 to DNS — --command's apt install is in the same window and I did not time it separately. The 4:00 is from the source, not from the subtraction; the subtraction is only consistent with it.

Cost on this fleet: 3 × 4 min at $38.19/hr aggregate ≈ $7.6 of retry per fleet launch, and it recurs on every relaunch.

Suggested fix

Distinguish permanent from transient with a control resolution rather than by the exit code alone. Either is cheap:

  • resolve the endpoint host from the controller once before entering the loop — if it's NXDOMAIN there, it will not become resolvable on the guest either, so don't start a 4-minute wait; or
  • on the first exit 6, have the guest resolve a control name alongside the endpoint (amazonaws.com, or the IMDS address it already reached successfully). Resolver up + endpoint unresolvable ⇒ permanent, break immediately. Resolver down ⇒ transient, keep the existing behavior.

The second one is strictly better because it tests the thing the comment is actually worried about: whether the instance's resolver is live yet. The exit code alone can't answer that, which is why it's currently answered by waiting.

A shorter deadline would not be a fix — it trades a known cost for a broken feature in the case the comment documents.

Related: no per-launch way to skip registration at all (filed separately).

Activity

  1. scttfrdmn commented on Aug 20, 2026

    @scttfrdmn
    ContributorAuthor

    Companion: spawn#549 — there is also no --no-dns to opt out of the wait, and dns.enabled is parsed but never read, so the config key that looks like the off-ramp is inert. Different files, different fixes; either one alone leaves a caller paying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions