broker: DigitalOcean.Destroy has no retry on a transient DO 5xx — release leg reds on a single Gateway Timeout #749

Closed
opened 2026-08-24 17:45:36 +00:00 by matou-build-agent · 3 comments

Failure

Drive 20260824T164237Z, leg release (signature cd27eeace366) went RED with:

broker refused the release of rehearsal-c.idss.nz: 502 {"error":"broker: DigitalOcean refused: Gateway Timeout: error code: 504"}

All 19 prior legs were green (artifacts/legs.json); this is the terminal honesty leg. The test's own POST is at app/tests/e2e/journey.rented.spec.ts:686-694.

Trace

  • broker/internal/broker/http.go:245-261 — the POST /v1/gateways/release handler wraps any error from Rentals.Release as a bare http.StatusBadGateway (502), passing the underlying message through verbatim (http.go:261).
  • broker/internal/broker/rentals.go:339-352 (Rentals.Release) calls r.prov.Destroy(ctx, serverID) once and returns its error straight through with no retry of its own.
  • broker/internal/broker/provider_do.go:179-194 (DigitalOcean.Destroy) issues exactly one DELETE /v2/droplets/{id} call via d.do (provider_do.go:420-448). DO answered that single call with a 504 Gateway Timeout, which d.do turns into a terminal *doRefusal (provider_do.go:437-446) — there is no loop, no backoff, nothing that distinguishes a transient gateway blip from a real refusal.

This is asymmetric with the other two DO call sites in the same file, both of which already retry transient failures, both hardened after past DO-blip incidents:

  • ensureSSHKey (provider_do.go:322-364) retries up to sshKeyPostRetries (=3, provider_do.go:60) — comment at provider_do.go:318-321 cites #677 ("a raw 404 from a post-create-style infra blip").
  • pollActive (provider_do.go:368-416) tolerates GET errors mid-poll and keeps trying — comment at provider_do.go:378-384 cites #672.

Destroy never got the equivalent treatment, so the one DO call in the release path that is NOT already hardened against a transient 5xx is exactly the one that redded this drive.

Not a leak

The droplet at 134.199.144.149 still answering ping/ssh after the red (logs/droplet-do-forensics.txt) is expected — the harness's keep-on-red contract (#716, app/tests/e2e/fixtures/rented.ts:162) deliberately preserves a red drive's box for evidence, and the pre-rent sweep (#748, scripts/lib/rehearsal-droplet.sh:648) reaps a kept-on-red box before the next same-slug drive claims it. No standing-drive violation here, no separate residual to hand back.

Suspected layer / what plugging needs

Provider layer (broker/internal/broker/provider_do.go), specifically DigitalOcean.Destroy. This needs a design call, not a mechanical edit:

  • which DO statuses on the DELETE count as retryable (504 certainly; worth deciding on 502/503 too, and on d.client.Do network errors);
  • how many attempts and what backoff (mirror sshKeyPostRetries + d.PollInterval, or its own budget);
  • whether the same retry should also wrap dropletName's GET (provider_do.go:199-211), which runs before the DELETE and could hit the same transient class.

A fix should add a scripted-fakeDO test alongside the existing TestDO_DestroyTreats404AsGone / TestDO_DestroyReapsTheDropletsSSHKey (provider_do_test.go:479-549) that has the DELETE fail once with a 504 then succeed, asserting Destroy still returns nil.

(Recent healer history shown for #720 is for an unrelated signature/leg — enroll-configure, sig a26965b5356b — no prior resistance on this signature.)

drive 20260824T164237Z red at release: broker refused the release of rehearsal-c.idss.nz: 502 {"error":"broker: DigitalOcean refused: Gateway Timeout: error code: 504"}
evidence: test-results/…/20260824T164237Z/ on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596)

## Failure Drive `20260824T164237Z`, leg `release` (signature `cd27eeace366`) went RED with: ``` broker refused the release of rehearsal-c.idss.nz: 502 {"error":"broker: DigitalOcean refused: Gateway Timeout: error code: 504"} ``` All 19 prior legs were green (`artifacts/legs.json`); this is the terminal honesty leg. The test's own POST is at `app/tests/e2e/journey.rented.spec.ts:686-694`. ## Trace - `broker/internal/broker/http.go:245-261` — the `POST /v1/gateways/release` handler wraps any error from `Rentals.Release` as a bare `http.StatusBadGateway` (502), passing the underlying message through verbatim (`http.go:261`). - `broker/internal/broker/rentals.go:339-352` (`Rentals.Release`) calls `r.prov.Destroy(ctx, serverID)` once and returns its error straight through with no retry of its own. - `broker/internal/broker/provider_do.go:179-194` (`DigitalOcean.Destroy`) issues exactly **one** `DELETE /v2/droplets/{id}` call via `d.do` (provider_do.go:420-448). DO answered that single call with a 504 Gateway Timeout, which `d.do` turns into a terminal `*doRefusal` (provider_do.go:437-446) — there is no loop, no backoff, nothing that distinguishes a transient gateway blip from a real refusal. This is asymmetric with the other two DO call sites in the same file, both of which already retry transient failures, both hardened after past DO-blip incidents: - `ensureSSHKey` (provider_do.go:322-364) retries up to `sshKeyPostRetries` (=3, provider_do.go:60) — comment at provider_do.go:318-321 cites #677 ("a raw 404 from a post-create-style infra blip"). - `pollActive` (provider_do.go:368-416) tolerates GET errors mid-poll and keeps trying — comment at provider_do.go:378-384 cites #672. `Destroy` never got the equivalent treatment, so the one DO call in the release path that is NOT already hardened against a transient 5xx is exactly the one that redded this drive. ## Not a leak The droplet at `134.199.144.149` still answering ping/ssh after the red (`logs/droplet-do-forensics.txt`) is expected — the harness's keep-on-red contract (#716, `app/tests/e2e/fixtures/rented.ts:162`) deliberately preserves a red drive's box for evidence, and the pre-rent sweep (#748, `scripts/lib/rehearsal-droplet.sh:648`) reaps a kept-on-red box before the next same-slug drive claims it. No standing-drive violation here, no separate residual to hand back. ## Suspected layer / what plugging needs Provider layer (`broker/internal/broker/provider_do.go`), specifically `DigitalOcean.Destroy`. This needs a design call, not a mechanical edit: - which DO statuses on the DELETE count as retryable (504 certainly; worth deciding on 502/503 too, and on `d.client.Do` network errors); - how many attempts and what backoff (mirror `sshKeyPostRetries` + `d.PollInterval`, or its own budget); - whether the same retry should also wrap `dropletName`'s GET (provider_do.go:199-211), which runs before the DELETE and could hit the same transient class. A fix should add a scripted-fakeDO test alongside the existing `TestDO_DestroyTreats404AsGone` / `TestDO_DestroyReapsTheDropletsSSHKey` (provider_do_test.go:479-549) that has the DELETE fail once with a 504 then succeed, asserting `Destroy` still returns nil. (Recent healer history shown for #720 is for an unrelated signature/leg — `enroll-configure`, sig `a26965b5356b` — no prior resistance on this signature.) drive `20260824T164237Z` red at `release`: `broker refused the release of rehearsal-c.idss.nz: 502 {"error":"broker: DigitalOcean refused: Gateway Timeout: error code: 504"}` evidence: `test-results/…/20260824T164237Z/` on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596) <!-- rehearsal-sig: cd27eeace366 -->
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=9760
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=9760 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

Ruled by agent under ADR 0174 — veto anytime.

The ticket flagged the retry policy for DigitalOcean.Destroy as a design call. It is a two-way door: the whole change is a bounded transient-retry on the teardown path, revertible by a later commit and proven by scripted-fakeDO tests. It touches nothing on the one-way-door list (no credentials, no security widening, no member trust accept, no data destruction — a retry makes the intended delete more reliable, it does not delete anything extra; a transient failure today leaves the box up, the opposite of over-destruction — no non-routine spend).

The ruling (the three design questions the ticket raised):

  1. Which statuses are retryable. The transient server-side class — any DO *doRefusal with status >= 500 (so 502/503/504 and 500) — plus any non-typed error from client.Do (a network/timeout error, which do() wraps rather than turning into a *doRefusal). A typed 4xx (404 gone, 422 duplicate, 401 auth) is terminal and surfaces on the first call — never spun on. This is narrower than ensureSSHKey's blanket non-422 retry: a genuine refusal on the release leg still fails fast.
  2. Attempts / backoff. destroyRetries = 3, spaced by d.PollInterval via sleepCtx (context-cancellable) — mirrors sshKeyPostRetries (#677) and the same transient class pollActive rides out (#672). Small and fixed: the release leg is a drive's last honest leg, so a persistent failure must surface fast, not spin on a bad token.
  3. Wrap dropletName's pre-delete GET too? Yes — it runs before the DELETE and hits the same transient class; a blip there would silently skip the #708 key reap (a stale-key leak). Both teardown calls now go through one doRetryTransient helper.

What proves it: TestDO_DestroyRetriesTransientDeleteGatewayTimeout (one 504 then success → Destroy returns nil, exactly 2 DELETEs), TestDO_DestroyFailsLoudWhenDeleteNeverRecovers (every DELETE 504s → fails loud after exactly destroyRetries, no masked live box, ADR 0047), and TestDO_DestroyDoesNotRetryTerminalRefusal (a 401 → surfaced on the first DELETE, budget not spent). All existing DO contract tests still green.

**Ruled by agent under ADR 0174 — veto anytime.** The ticket flagged the retry policy for `DigitalOcean.Destroy` as a design call. It is a **two-way door**: the whole change is a bounded transient-retry on the teardown path, revertible by a later commit and proven by scripted-fakeDO tests. It touches nothing on the one-way-door list (no credentials, no security widening, no member trust accept, no data destruction — a retry makes the *intended* delete more reliable, it does not delete anything extra; a transient failure today leaves the box *up*, the opposite of over-destruction — no non-routine spend). **The ruling (the three design questions the ticket raised):** 1. **Which statuses are retryable.** The transient server-side class — any DO `*doRefusal` with status `>= 500` (so 502/503/**504** and 500) — plus any non-typed error from `client.Do` (a network/timeout error, which `do()` wraps rather than turning into a `*doRefusal`). A typed 4xx (404 gone, 422 duplicate, 401 auth) is terminal and surfaces on the first call — never spun on. This is *narrower* than `ensureSSHKey`'s blanket non-422 retry: a genuine refusal on the release leg still fails fast. 2. **Attempts / backoff.** `destroyRetries = 3`, spaced by `d.PollInterval` via `sleepCtx` (context-cancellable) — mirrors `sshKeyPostRetries` (#677) and the same transient class `pollActive` rides out (#672). Small and fixed: the release leg is a drive's last honest leg, so a persistent failure must surface fast, not spin on a bad token. 3. **Wrap `dropletName`'s pre-delete GET too?** Yes — it runs before the DELETE and hits the same transient class; a blip there would silently skip the #708 key reap (a stale-key leak). Both teardown calls now go through one `doRetryTransient` helper. **What proves it:** `TestDO_DestroyRetriesTransientDeleteGatewayTimeout` (one 504 then success → `Destroy` returns nil, exactly 2 DELETEs), `TestDO_DestroyFailsLoudWhenDeleteNeverRecovers` (every DELETE 504s → fails loud after exactly `destroyRetries`, no masked live box, ADR 0047), and `TestDO_DestroyDoesNotRetryTerminalRefusal` (a 401 → surfaced on the first DELETE, budget not spent). All existing DO contract tests still green.
Author
Member

close-report for #749 — status success

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

envelope
{
  "issue": 749,
  "status": "success",
  "commits": [
    "a89f392b7eb6384507423117cc003b1218beb87d"
  ],
  "changed_files": [
    "broker/internal/broker/provider_do.go",
    "broker/internal/broker/provider_do_test.go",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go test ./internal/broker/ (in broker/)",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go build ./... && go vet ./internal/broker/ (in broker/)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "DigitalOcean.Destroy retries a transient DO 5xx on the DELETE (504 no longer terminal)": "doRetryTransient + isTransientDO in provider_do.go; TestDO_DestroyRetriesTransientDeleteGatewayTimeout (one 504 then success -> nil, exactly 2 DELETEs)",
    "Retry budget is bounded and a persistent failure surfaces loud (ADR 0047, no masked live box)": "destroyRetries=3 spaced by PollInterval; TestDO_DestroyFailsLoudWhenDeleteNeverRecovers (fails after exactly destroyRetries)",
    "Retry is scoped to the transient class; a terminal 4xx is not spun on": "isTransientDO retries status>=500 or non-typed errors only; TestDO_DestroyDoesNotRetryTerminalRefusal (401 surfaced on first DELETE)",
    "dropletName's pre-delete GET hardened against the same blip so the #708 key reap is not silently skipped": "dropletName now uses doRetryTransient (provider_do.go)",
    "Design call ruled per the ticket": "ADR 0174 two-way-door ruling posted to #749"
  },
  "summary": "DigitalOcean.Destroy's teardown DELETE and pre-delete GET now retry a transient DO 5xx/network blip within a fixed budget, so a lone 504 no longer reds the release leg.",
  "blockers": []
}
**close-report** for #749 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 749, "status": "success", "commits": [ "a89f392b7eb6384507423117cc003b1218beb87d" ], "changed_files": [ "broker/internal/broker/provider_do.go", "broker/internal/broker/provider_do_test.go", "STATUS.md" ], "tests": [ { "command": "nix develop .#go-ci -c go test ./internal/broker/ (in broker/)", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go build ./... && go vet ./internal/broker/ (in broker/)", "exit_code": 0 } ], "criteria": { "DigitalOcean.Destroy retries a transient DO 5xx on the DELETE (504 no longer terminal)": "doRetryTransient + isTransientDO in provider_do.go; TestDO_DestroyRetriesTransientDeleteGatewayTimeout (one 504 then success -> nil, exactly 2 DELETEs)", "Retry budget is bounded and a persistent failure surfaces loud (ADR 0047, no masked live box)": "destroyRetries=3 spaced by PollInterval; TestDO_DestroyFailsLoudWhenDeleteNeverRecovers (fails after exactly destroyRetries)", "Retry is scoped to the transient class; a terminal 4xx is not spun on": "isTransientDO retries status>=500 or non-typed errors only; TestDO_DestroyDoesNotRetryTerminalRefusal (401 surfaced on first DELETE)", "dropletName's pre-delete GET hardened against the same blip so the #708 key reap is not silently skipped": "dropletName now uses doRetryTransient (provider_do.go)", "Design call ruled per the ticket": "ADR 0174 two-way-door ruling posted to #749" }, "summary": "DigitalOcean.Destroy's teardown DELETE and pre-delete GET now retry a transient DO 5xx/network blip within a fixed budget, so a lone 504 no longer reds the release leg.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#749
No description provided.