rented gateway gets no DNS-01 delegation: the challenge fact is read one second after it is written, reads empty, and nothing ever re-points #915

Closed
opened 2026-08-28 03:01:55 +00:00 by ben · 2 comments
Owner

The failure

A rented gateway deploys, both TLS doors never answer, and activation reds after 648 s (#905, drive 20260827T144343Z, 15 green / 2 red). The zone shows why — for slug rehearsal-c, checked live against the authoritative nameserver:

name type value verdict
rehearsal-c.idss.nz A 168.144.172.20 correct
*.rehearsal-c CNAME rehearsal-c.idss.nz. correct
_acme-challenge.rehearsal-c CNAME rehearsal-c.idss.nz. wrong target — points at the apex
acme.rehearsal-c NS — absent — no delegation

DNS-01 can never validate, so Caddy waits on :443 forever and neither door comes up.

The gateway is NOT at fault — it held a valid fulldomain the whole time

/var/lib/idss-acmedns/ on the live gateway (168.144.172.20), all written 14:58:

caddy.env          IDSS_ACMEDNS_{USERNAME,PASSWORD,SUBDOMAIN,SERVER_URL} all set
fulldomain         07feca20-5f4c-4c51-a570-24c0f7fc4c70.acme.rehearsal-c.idss.nz
registration.json

acme-dns-register succeeded. (The lone curl: (7) … 127.0.0.1:8081 in its journal at 14:58:35 is the health poll's first iteration, retried green a second later — #431's 300 s readiness gate working as designed. It is not a failure; do not chase it.)

Root cause — a best-effort read at a moment the fact cannot yet exist, and no second chance

ChallengeSource.AcmeChallenge (internal/fleetwire/challenge.go:81) fetches the fulldomain over SSH from the gateway and, by explicit design, returns honest-absent "" — never an error — in three cases:

  • sshPort fails → return "", nil ("no forward yet")
  • the SSH run fails → return "", nil ("gateway unreachable")
  • the fact file is missing → cat … 2>/dev/null || true → empty stdout, zero exit

The point request went out at 14:58:37, one second after acme-dns-register finished at 14:58:36. It read empty, and the broker duly wired the name with A + wildcard and no delegation (ADR 0100: never fabricate one).

That much is correct behaviour. The gap is what happens next: nothing ever re-points. The absent delegation is permanent for the life of that name, and the function's own comment — "a missing challenge only decorates the name-wiring, so it must never abort it" — is backwards for DNS-01. Without the delegation the door can never obtain a certificate. The "decoration" is load-bearing, so an absent challenge is not a cosmetic degradation; it is a guaranteed dead door.

Fix — pick one, they are not equivalent

  1. Gate the point on the fact (preferred): before wiring, wait for the fulldomain with a bounded budget, the shape this repo already uses twice (vm.Manager.WaitReady/pollReady; DDR 0192's CarrierConfig.ConnectTimeout/ConnectPoll, added for #691's identical "started ≠ ready" race). The fact is written seconds after the gateway boots, so a short budget suffices.
  2. Re-point when the fact appears: the gateway already heartbeats the broker (renderAcmeDNSGate's comment names "the _acme-challenge.<apex> CNAME the broker's heartbeat publishes"). Carry the challenge on the heartbeat and let the broker complete the record set late. This also self-heals a gateway that re-registers.
  3. Fail loud (ADR 0100) if the wiring completes with no delegation, instead of returning a name that cannot ever serve TLS. Weakest alone — it converts a silent 648 s death into a fast one — but it is the honest floor and pairs well with 1 or 2.

Do not "fix" this by re-running PutRecords against the current zone: the record is wrong because its input was empty, and a redeploy with the same empty input rewrites the same wrong CNAME.

Acceptance

  • A rented gateway's _acme-challenge.<slug> CNAME names the gateway's own acme-dns fulldomain, and acme.<slug> carries the NS delegation, before Caddy first orders a certificate.
  • A challenge fact that is not yet readable at point time does not permanently strand the name — either the point waits, or a later pass completes the record set.
  • A name wired without a delegation is reported loudly rather than left to red 648 s downstream at activation.
  • Regression cover at the seam that already owns this shape, so the next change cannot silently reintroduce a delegation-less name.

Evidence

  • test-results/drive-device/20260827T144343Z/ on elitebook-03 — artifacts/verdict.json, artifacts/legs.json, logs/founding-state.log.
  • Live gateway 168.144.172.20 (droplet 595628182) still standing at filing time: /var/lib/idss-acmedns/{fulldomain,caddy.env,registration.json}, and journalctl -u acme-dns-register.
  • Zone read against andy.ns.cloudflare.com. Note for anyone verifying: *.idss.nz has a wildcard A record, so every name under the zone resolves and an A-record probe proves nothing — query the specific type (NS, CNAME) or you will misread deleted records as present (#887).

Filed by the watch under ADR 0174 at Ben's direction, as the remaining half of #905 (its other half, the DigitalOcean token, is resolved — the broker now runs a credential with delete scope and has logged zero 403s since 22:34:58Z). My first diagnosis on #905 blamed a readiness race in acme-dns-register; that was wrong and is corrected on that ticket.

## The failure A rented gateway deploys, both TLS doors never answer, and `activation` reds after 648 s (`#905`, drive `20260827T144343Z`, 15 green / 2 red). The zone shows why — for slug `rehearsal-c`, checked live against the authoritative nameserver: | name | type | value | verdict | |---|---|---|---| | `rehearsal-c.idss.nz` | A | `168.144.172.20` | correct | | `*.rehearsal-c` | CNAME | `rehearsal-c.idss.nz.` | correct | | `_acme-challenge.rehearsal-c` | CNAME | `rehearsal-c.idss.nz.` | **wrong target — points at the apex** | | `acme.rehearsal-c` | NS | — | **absent — no delegation** | DNS-01 can never validate, so Caddy waits on `:443` forever and neither door comes up. ## The gateway is NOT at fault — it held a valid fulldomain the whole time `/var/lib/idss-acmedns/` on the live gateway (`168.144.172.20`), all written 14:58: ``` caddy.env IDSS_ACMEDNS_{USERNAME,PASSWORD,SUBDOMAIN,SERVER_URL} all set fulldomain 07feca20-5f4c-4c51-a570-24c0f7fc4c70.acme.rehearsal-c.idss.nz registration.json ``` `acme-dns-register` succeeded. (The lone `curl: (7) … 127.0.0.1:8081` in its journal at 14:58:35 is the **health poll's first iteration**, retried green a second later — `#431`'s 300 s readiness gate working as designed. It is not a failure; do not chase it.) ## Root cause — a best-effort read at a moment the fact cannot yet exist, and no second chance `ChallengeSource.AcmeChallenge` (`internal/fleetwire/challenge.go:81`) fetches the fulldomain **over SSH from the gateway** and, by explicit design, returns honest-absent `""` — never an error — in three cases: - `sshPort` fails → `return "", nil` ("no forward yet") - the SSH run fails → `return "", nil` ("gateway unreachable") - the fact file is missing → `cat … 2>/dev/null || true` → empty stdout, zero exit The point request went out at **14:58:37**, **one second** after `acme-dns-register` finished at 14:58:36. It read empty, and the broker duly wired the name with A + wildcard and **no delegation** (`ADR 0100`: never fabricate one). That much is correct behaviour. The gap is what happens next: **nothing ever re-points.** The absent delegation is permanent for the life of that name, and the function's own comment — *"a missing challenge only decorates the name-wiring, so it must never abort it"* — is backwards for DNS-01. Without the delegation the door can **never** obtain a certificate. The "decoration" is load-bearing, so an absent challenge is not a cosmetic degradation; it is a guaranteed dead door. ## Fix — pick one, they are not equivalent 1. **Gate the point on the fact** (preferred): before wiring, wait for the fulldomain with a bounded budget, the shape this repo already uses twice (`vm.Manager.WaitReady`/`pollReady`; DDR 0192's `CarrierConfig.ConnectTimeout`/`ConnectPoll`, added for `#691`'s identical "started ≠ ready" race). The fact is written seconds after the gateway boots, so a short budget suffices. 2. **Re-point when the fact appears**: the gateway already heartbeats the broker (`renderAcmeDNSGate`'s comment names "the `_acme-challenge.<apex>` CNAME the broker's heartbeat publishes"). Carry the challenge on the heartbeat and let the broker complete the record set late. This also self-heals a gateway that re-registers. 3. **Fail loud** (`ADR 0100`) if the wiring completes with no delegation, instead of returning a name that cannot ever serve TLS. Weakest alone — it converts a silent 648 s death into a fast one — but it is the honest floor and pairs well with 1 or 2. Do **not** "fix" this by re-running `PutRecords` against the current zone: the record is wrong because its *input* was empty, and a redeploy with the same empty input rewrites the same wrong CNAME. ## Acceptance - A rented gateway's `_acme-challenge.<slug>` CNAME names the gateway's own acme-dns fulldomain, and `acme.<slug>` carries the NS delegation, before Caddy first orders a certificate. - A challenge fact that is not yet readable at point time does not permanently strand the name — either the point waits, or a later pass completes the record set. - A name wired without a delegation is reported loudly rather than left to red 648 s downstream at `activation`. - Regression cover at the seam that already owns this shape, so the next change cannot silently reintroduce a delegation-less name. ## Evidence - `test-results/drive-device/20260827T144343Z/` on `elitebook-03` — `artifacts/verdict.json`, `artifacts/legs.json`, `logs/founding-state.log`. - Live gateway `168.144.172.20` (droplet `595628182`) still standing at filing time: `/var/lib/idss-acmedns/{fulldomain,caddy.env,registration.json}`, and `journalctl -u acme-dns-register`. - Zone read against `andy.ns.cloudflare.com`. **Note for anyone verifying:** `*.idss.nz` has a wildcard **A** record, so every name under the zone resolves and an A-record probe proves nothing — query the specific type (`NS`, `CNAME`) or you will misread deleted records as present (`#887`). *Filed by the watch under ADR 0174 at Ben's direction, as the remaining half of #905 (its other half, the DigitalOcean token, is resolved — the broker now runs a credential with delete scope and has logged zero 403s since 22:34:58Z). My first diagnosis on #905 blamed a readiness race in `acme-dns-register`; that was wrong and is corrected on that ticket.*

swarm-claim host=matou-dev-server-01 run=12993
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=12993 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #915 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 915,
  "status": "success",
  "commits": [
    "6fc7fba1"
  ],
  "changed_files": [
    "internal/fleetwire/challenge.go",
    "internal/fleetwire/challenge_test.go",
    "app/helper/cmd/helper/wiring_prod.go",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go test ./internal/fleetwire/... ./internal/founding/...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go build ./...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go vet ./...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c golangci-lint run ./internal/fleetwire/... ./app/helper/...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A rented gateway's _acme-challenge.<slug> CNAME names the gateway's own acme-dns fulldomain, and acme.<slug> carries the NS delegation, before Caddy first orders a certificate": "wireName reads the challenge before PointSubdomain (founding/standup.go); AcmeChallenge now polls until the fulldomain is readable (internal/fleetwire/challenge.go waitForChallenge) rather than a one-shot best-effort read, so PointSubdomain receives the real fulldomain and the broker writes the CNAME+NS delegation. Proven by TestChallengeSource_GatesOnFactAndReturnsItWhenItAppears.",
    "A challenge fact that is not yet readable at point time does not permanently strand the name — either the point waits, or a later pass completes the record set": "Option 1 (the point waits): ChallengeTimeout/ChallengePoll gate the point on the fact; a fact that appears late is waited out. Proven by TestChallengeSource_GatesOnFactAndReturnsItWhenItAppears (two empty reads waited out before the fact appears).",
    "A name wired without a delegation is reported loudly rather than left to red 648 s downstream at activation": "On budget exhaustion AcmeChallenge returns an error ('gateway published no acme-dns fulldomain within ...'); founding's wireName treats a challenge-read error as fatal to the wiring, surfacing it at wire time. Proven by TestChallengeSource_ExhaustedBudgetFailsLoud.",
    "Regression cover at the seam that already owns this shape, so the next change cannot silently reintroduce a delegation-less name": "Three new seam tests in internal/fleetwire/challenge_test.go (gates-on-fact, exhausted-budget-fails-loud, context-cancellation); the three existing single-shot honest-absent tests still hold for the zero-budget contract."
  },
  "summary": "AcmeChallenge now gates the DNS-01 point on the gateway's acme-dns fulldomain fact (bounded poll, fails loud on exhaustion), so a one-second read race can no longer wire a delegation-less name that reds 648 s later at activation.",
  "blockers": []
}
**close-report** for #915 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 915, "status": "success", "commits": [ "6fc7fba1" ], "changed_files": [ "internal/fleetwire/challenge.go", "internal/fleetwire/challenge_test.go", "app/helper/cmd/helper/wiring_prod.go", "STATUS.md" ], "tests": [ { "command": "nix develop .#go-ci -c go test ./internal/fleetwire/... ./internal/founding/...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go build ./...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go vet ./...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c golangci-lint run ./internal/fleetwire/... ./app/helper/...", "exit_code": 0 } ], "criteria": { "A rented gateway's _acme-challenge.<slug> CNAME names the gateway's own acme-dns fulldomain, and acme.<slug> carries the NS delegation, before Caddy first orders a certificate": "wireName reads the challenge before PointSubdomain (founding/standup.go); AcmeChallenge now polls until the fulldomain is readable (internal/fleetwire/challenge.go waitForChallenge) rather than a one-shot best-effort read, so PointSubdomain receives the real fulldomain and the broker writes the CNAME+NS delegation. Proven by TestChallengeSource_GatesOnFactAndReturnsItWhenItAppears.", "A challenge fact that is not yet readable at point time does not permanently strand the name — either the point waits, or a later pass completes the record set": "Option 1 (the point waits): ChallengeTimeout/ChallengePoll gate the point on the fact; a fact that appears late is waited out. Proven by TestChallengeSource_GatesOnFactAndReturnsItWhenItAppears (two empty reads waited out before the fact appears).", "A name wired without a delegation is reported loudly rather than left to red 648 s downstream at activation": "On budget exhaustion AcmeChallenge returns an error ('gateway published no acme-dns fulldomain within ...'); founding's wireName treats a challenge-read error as fatal to the wiring, surfacing it at wire time. Proven by TestChallengeSource_ExhaustedBudgetFailsLoud.", "Regression cover at the seam that already owns this shape, so the next change cannot silently reintroduce a delegation-less name": "Three new seam tests in internal/fleetwire/challenge_test.go (gates-on-fact, exhausted-budget-fails-loud, context-cancellation); the three existing single-shot honest-absent tests still hold for the zero-budget contract." }, "summary": "AcmeChallenge now gates the DNS-01 point on the gateway's acme-dns fulldomain fact (bounded poll, fails loud on exhaustion), so a one-second read race can no longer wire a delegation-less name that reds 648 s later at activation.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#915
No description provided.