broker: Release's DO-teardown retry budget (3×5s) too thin for a sustained DigitalOcean outage — orphaned droplet survives a red drive up to the 24h TTL #756

Closed
opened 2026-08-24 21:36:28 +00:00 by matou-build-agent · 1 comment

Failure

Rehearsal drive 20260824T203650Z reds at the release leg. The broker's POST /v1/gateways/release for rehearsal-c.idss.nz returned 502:

broker refused the release of rehearsal-c.idss.nz: 502 {"error":"broker: DigitalOcean refused: Service Unavailable: {\"error\":\"unable to process request, please try again\"}"}

(tests/e2e/journey.rented.spec.ts:692, leg timing in artifacts/legs.json — release ran 13731ms before failing.)

Root cause

Rentals.Release (broker/internal/broker/rentals.go:362-388) calls DigitalOcean.Destroy (broker/internal/broker/provider_do.go:200-215), which already rides out transient DO 5xx blips via doRetryTransient (provider_do.go:481-499): transientRetries = 3 (provider_do.go:77) spaced by PollInterval (5s, provider_do.go:100) — a ~10-15s budget. The leg's 13731ms runtime matches that budget being exhausted, not a single blip: DigitalOcean's /v2/droplets/{id} DELETE was returning 503 ("unable to process request, please try again") for longer than ~15s. A failed Release never sets rental.Released = true (rentals.go:381), so the droplet is left live and un-torn-down.

http.go:260-261 turns any Release error straight into a 502 to the caller — there is no background retry path; the only other teardown mechanism is Reap (rentals.go:390-419), which only fires after the lease's TTL lapses. Default TTL is 24h (broker/cmd/broker/main.go:96, IDSS_GATEWAY_TTL), and this rental's heartbeat had just renewed it (leg heartbeat-repoint ran green immediately before release). So a release-time DO outage leaves an orphaned, billed droplet for up to 24h before the reaper would even attempt it again — and Reap uses the same thin retry budget, so it isn't guaranteed to succeed either if DO is still down.

Evidence this is live right now

droplet-do-forensics.txt in the run dir shows the box answering ping/ssh 2 minutes after the failed release. I confirmed directly via doctl compute droplet get 594866531 at filing time: droplet 594866531 / idss-gateway-rehearsal-c-8544 (168.144.165.255, rehearsal-c.idss.nz) is still active on the account. This needs a manual doctl compute droplet delete 594866531 (and DNS/broker-ledger cleanup) now — it is outside what this healer touches (infra state outside the checkout).

Suspected layer

broker/internal/broker/provider_do.go (retry budget/backoff for the teardown path) and broker/internal/broker/rentals.go (Release/Reap — no async reconciliation for a release that fails after the HTTP response budget is exhausted).

What plugging this needs

A design call, not a mechanical fix — options include: a longer/backed-off retry budget specifically on the release-teardown DELETE (bounded so the HTTP handler doesn't hang the caller indefinitely — maybe retry synchronously for a few seconds then hand off to an async retry loop that keeps trying until DO recovers, independent of Reap's TTL-gated sweep), and/or an operational alert when a Release exhausts its retries so a stray-billed-droplet isn't sitting silent for up to 24h. Also worth checking whether scripts/rental-reap.sh / the reap cron runs frequently enough that even the current design would catch this sooner than 24h in practice.

Signature: cd27eeace366.

drive 20260824T203650Z red at release: broker refused the release of rehearsal-c.idss.nz: 502 {"error":"broker: DigitalOcean refused: Service Unavailable: {\"error\":\"unable to process request, please try again\"}"}
evidence: test-results/…/20260824T203650Z/ on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596)

## Failure Rehearsal drive `20260824T203650Z` reds at the `release` leg. The broker's `POST /v1/gateways/release` for `rehearsal-c.idss.nz` returned 502: ``` broker refused the release of rehearsal-c.idss.nz: 502 {"error":"broker: DigitalOcean refused: Service Unavailable: {\"error\":\"unable to process request, please try again\"}"} ``` (`tests/e2e/journey.rented.spec.ts:692`, leg timing in `artifacts/legs.json` — `release` ran 13731ms before failing.) ## Root cause `Rentals.Release` (`broker/internal/broker/rentals.go:362-388`) calls `DigitalOcean.Destroy` (`broker/internal/broker/provider_do.go:200-215`), which already rides out transient DO 5xx blips via `doRetryTransient` (`provider_do.go:481-499`): `transientRetries = 3` (`provider_do.go:77`) spaced by `PollInterval` (5s, `provider_do.go:100`) — a ~10-15s budget. The leg's 13731ms runtime matches that budget being exhausted, not a single blip: DigitalOcean's `/v2/droplets/{id}` DELETE was returning 503 ("unable to process request, please try again") for longer than ~15s. A failed `Release` never sets `rental.Released = true` (`rentals.go:381`), so the droplet is left live and un-torn-down. `http.go:260-261` turns any `Release` error straight into a 502 to the caller — there is no background retry path; the only other teardown mechanism is `Reap` (`rentals.go:390-419`), which only fires after the lease's TTL lapses. Default TTL is 24h (`broker/cmd/broker/main.go:96`, `IDSS_GATEWAY_TTL`), and this rental's heartbeat had just renewed it (leg `heartbeat-repoint` ran green immediately before `release`). So a release-time DO outage leaves an orphaned, billed droplet for up to 24h before the reaper would even attempt it again — and Reap uses the same thin retry budget, so it isn't guaranteed to succeed either if DO is still down. ## Evidence this is live right now `droplet-do-forensics.txt` in the run dir shows the box answering ping/ssh 2 minutes after the failed release. I confirmed directly via `doctl compute droplet get 594866531` at filing time: droplet `594866531` / `idss-gateway-rehearsal-c-8544` (168.144.165.255, `rehearsal-c.idss.nz`) is **still `active`** on the account. This needs a manual `doctl compute droplet delete 594866531` (and DNS/broker-ledger cleanup) now — it is outside what this healer touches (infra state outside the checkout). ## Suspected layer `broker/internal/broker/provider_do.go` (retry budget/backoff for the teardown path) and `broker/internal/broker/rentals.go` (`Release`/`Reap` — no async reconciliation for a release that fails after the HTTP response budget is exhausted). ## What plugging this needs A design call, not a mechanical fix — options include: a longer/backed-off retry budget specifically on the release-teardown DELETE (bounded so the HTTP handler doesn't hang the caller indefinitely — maybe retry synchronously for a few seconds then hand off to an async retry loop that keeps trying until DO recovers, independent of `Reap`'s TTL-gated sweep), and/or an operational alert when a `Release` exhausts its retries so a stray-billed-droplet isn't sitting silent for up to 24h. Also worth checking whether `scripts/rental-reap.sh` / the reap cron runs frequently enough that even the current design would catch this sooner than 24h in practice. Signature: `cd27eeace366`. drive `20260824T203650Z` red at `release`: `broker refused the release of rehearsal-c.idss.nz: 502 {"error":"broker: DigitalOcean refused: Service Unavailable: {\"error\":\"unable to process request, please try again\"}"}` evidence: `test-results/…/20260824T203650Z/` 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

Close report — the design call is made, shipped, and proven offline

Ruled by agent under ADR 0174 — veto anytime. Two-way door: one revertible
commit in the broker's own ledger logic, proven by seam tests, nothing on the
one-way-door list. Commit b9a3adfd.

The ruling

The ticket asked for a design call between "a longer/backed-off retry budget" and
"an async retry loop independent of Reap". I ruled neither, and both — the
retry budget stays exactly where it is, and the async retry loop already exists.

The budget (transientRetries = 3 × the 5s poll, ~15s) is correct: a persistent
refusal must surface fast rather than hang the caller, which is why it was written
small on purpose (#749/#751). Growing it only moves the cliff. The real defect is
that giving the lease up and completing its teardown are two different facts, and
only the second was ever recorded
— so when the budget was exhausted, Release
returned its error and nothing was left holding the teardown.

And IDSS already runs a standing teardown loop: RunReaper, every 5 minutes
(broker/cmd/broker/main.go:70). The only reason it could not help is that it
reaped on one clock — the lease deadline — which was 24h out and being pushed
further out by the surviving box's own heartbeat (GOTCHAS #76). So the fix is to
record the owed teardown and let the reaper carry it, rather than bolt on a second
retry mechanism with its own lifecycle.

Shipped (broker/internal/broker/rentals.go):

  1. A refused Destroy marks the rental ReleaseOwed and persists it — an
    additive omitempty field, so the v1 ledger schema is unchanged and an older
    binary simply degrades to today's behaviour (no version bump, no migration).
    It logs the still-live droplet's id and IP at ERROR: that is the
    "operational alert" the ticket asked for — a stray billed box is never silent.
  2. Reap reaps on either clock — lapsed lease OR owed teardown — so the
    5-minute pass is the retry loop and its interval is the backoff. What bounds
    the orphan is now the length of the outage, not the length of the lease.
  3. Renew refuses a release-owed lease (ErrReleasing, 409 on the wire).
    Without this the fix would not hold: the control-plane runs ON the rented box,
    so a box that survives its own release renews its own lease forever (#741) and
    no deadline-based reaper ever fires.

The caller still gets its honest 502 (ADR 0100) — the release did not land —
now naming who is carrying the retry.

Proof

Red-before-green in broker/internal/broker/rentals_release_owed_test.go (6 cases:
owed on refusal + durable across a restart; reaped without waiting for the TTL;
still owed across three passes while the provider is down; renew refused and the
deadline unmoved; a hand-retry converges once DO answers; a clean release owes
nothing) plus the wire case in http_rent_test.go (502 says "the teardown is
owed", renew 409, 204 once DO answers). First run failed to build on the missing
field/error; the HTTP case then failed on renew … = 502, want 409 before the
mapping was wired.

  • broker go test ./... green, go vet clean, gofmt clean.
  • Forgejo CI on b9a3adfd: seam ✅, publish ✅, publish-broker ✅.

Docs: ADR 0189 amended (third amendment, "a REFUSED teardown is owed, not
forgotten"), GOTCHAS #81, broker/README.md, STATUS.md (lead + milestone log).

The live orphan — destroyed

Droplet 594866531 (idss-gateway-rehearsal-c-8544, 168.144.165.255) was
still active when this session started. Destroyed; doctl compute droplet get
now 404s and doctl compute droplet list --tag-name idss-rental is empty.

Ruled two-way: it is an idss-gateway-rehearsal-* drive box — precisely the
class scripts/rental-reap.sh destroys unattended, and its 8h drive wall would
have destroyed this one at ~04:47Z regardless. Bringing that decision forward
claims no authority the hourly sweep does not already hold, and destroying a
member-facing gateway (the actual one-way door) was never in play. No ledger or
DNS surgery was needed: Rent's live-server probe (#652) and the reservation TTL
(#754) both self-heal a stale rehearsal-c binding.

On "does the sweep catch it sooner than 24h in practice?"

Checked, and the answer is yes but only by luck, and not during the outage that
matters
:

  • The cron is installed and hourly (47 * * * *, matou-workstation), and its 8h
    drive wall — not the lease — is what would have caught this box, at ~04:47Z.
  • That box wore no idss-rental-expires-<epoch> tag at all, confirming the
    deployed broker still predates #741. So in production today the wall is the
    only machine-side clock on a rented gateway.
  • Most importantly, rental-reap.log shows the 21:47Z sweep itself dying:
    CANNOT REAP — doctl could not list idss-rental droplets: … 504. During exactly
    the window that mints the orphan, the machine-side backstop is down too. That is
    why the fix had to land in the broker's own ledger rather than lean on the sweep.

Left open (named, not silently dropped)

  • The droplet's idss-rental-expires-<epoch> tag still reads the pre-release
    deadline after a refused release, because re-stamping it needs the very provider
    call that is failing. So the broker-independent sweep still judges such a box by
    its 8h wall, not by an owed teardown it cannot see. Recorded in the ADR
    amendment and GOTCHAS #81; deliberately not fixed by adding a second failing call
    to an error path.
  • This is not live yet. publish-broker ✅ put the b9a3adfd binary in the
    registry, but no broker-deploy job fired in the ~5 minutes after it, and the
    install leg is still gated on #690 (ready-for-human: the droplet one-time
    setup + BROKER_DEPLOY_SSH_KEY). Pre-existing gate, Ben's hands, not opened here.
## Close report — the design call is made, shipped, and proven offline **Ruled by agent under ADR 0174 — veto anytime.** Two-way door: one revertible commit in the broker's own ledger logic, proven by seam tests, nothing on the one-way-door list. Commit **`b9a3adfd`**. ### The ruling The ticket asked for a design call between "a longer/backed-off retry budget" and "an async retry loop independent of `Reap`". I ruled **neither, and both** — the retry budget stays exactly where it is, and the async retry loop already exists. The budget (`transientRetries` = 3 × the 5s poll, ~15s) is *correct*: a persistent refusal must surface fast rather than hang the caller, which is why it was written small on purpose (#749/#751). Growing it only moves the cliff. The real defect is that **giving the lease up and completing its teardown are two different facts, and only the second was ever recorded** — so when the budget was exhausted, `Release` returned its error and *nothing was left holding the teardown*. And IDSS already runs a standing teardown loop: `RunReaper`, every 5 minutes (`broker/cmd/broker/main.go:70`). The only reason it could not help is that it reaped on one clock — the lease deadline — which was 24h out and being pushed further out by the surviving box's own heartbeat (GOTCHAS #76). So the fix is to record the owed teardown and let the reaper carry it, rather than bolt on a second retry mechanism with its own lifecycle. Shipped (`broker/internal/broker/rentals.go`): 1. A refused `Destroy` marks the rental **`ReleaseOwed`** and persists it — an additive `omitempty` field, so the v1 ledger schema is unchanged and an older binary simply degrades to today's behaviour (no version bump, no migration). It logs the still-live droplet's **id and IP at ERROR**: that is the "operational alert" the ticket asked for — a stray billed box is never silent. 2. **`Reap` reaps on either clock** — lapsed lease OR owed teardown — so the 5-minute pass *is* the retry loop and its interval is the backoff. What bounds the orphan is now the length of the outage, not the length of the lease. 3. **`Renew` refuses a release-owed lease** (`ErrReleasing`, 409 on the wire). Without this the fix would not hold: the control-plane runs ON the rented box, so a box that survives its own release renews its own lease forever (#741) and no deadline-based reaper ever fires. The caller still gets its honest 502 (ADR 0100) — the release did **not** land — now naming who is carrying the retry. ### Proof Red-before-green in `broker/internal/broker/rentals_release_owed_test.go` (6 cases: owed on refusal + durable across a restart; reaped without waiting for the TTL; still owed across three passes while the provider is down; renew refused and the deadline unmoved; a hand-retry converges once DO answers; a clean release owes nothing) plus the wire case in `http_rent_test.go` (502 says "the teardown is owed", renew 409, 204 once DO answers). First run failed to build on the missing field/error; the HTTP case then failed on `renew … = 502, want 409` before the mapping was wired. - broker `go test ./...` green, `go vet` clean, `gofmt` clean. - Forgejo CI on `b9a3adfd`: `seam` ✅, `publish` ✅, `publish-broker` ✅. Docs: **ADR 0189 amended** (third amendment, "a REFUSED teardown is owed, not forgotten"), **GOTCHAS #81**, `broker/README.md`, `STATUS.md` (lead + milestone log). ### The live orphan — destroyed Droplet **`594866531`** (`idss-gateway-rehearsal-c-8544`, `168.144.165.255`) was still `active` when this session started. Destroyed; `doctl compute droplet get` now 404s and `doctl compute droplet list --tag-name idss-rental` is empty. Ruled two-way: it is an `idss-gateway-rehearsal-*` **drive box** — precisely the class `scripts/rental-reap.sh` destroys unattended, and its 8h drive wall would have destroyed this one at ~04:47Z regardless. Bringing that decision forward claims no authority the hourly sweep does not already hold, and destroying a member-facing gateway (the actual one-way door) was never in play. No ledger or DNS surgery was needed: `Rent`'s live-server probe (#652) and the reservation TTL (#754) both self-heal a stale `rehearsal-c` binding. ### On "does the sweep catch it sooner than 24h in practice?" Checked, and the answer is **yes but only by luck, and not during the outage that matters**: - The cron is installed and hourly (`47 * * * *`, matou-workstation), and its 8h drive wall — not the lease — is what would have caught this box, at ~04:47Z. - That box wore **no `idss-rental-expires-<epoch>` tag at all**, confirming the deployed broker still predates #741. So in production today the wall is the *only* machine-side clock on a rented gateway. - Most importantly, `rental-reap.log` shows the 21:47Z sweep itself dying: `CANNOT REAP — doctl could not list idss-rental droplets: … 504`. During exactly the window that mints the orphan, the machine-side backstop is down too. That is why the fix had to land in the broker's own ledger rather than lean on the sweep. ### Left open (named, not silently dropped) - The droplet's `idss-rental-expires-<epoch>` tag still reads the pre-release deadline after a refused release, because re-stamping it needs the very provider call that is failing. So the broker-independent sweep still judges such a box by its 8h wall, not by an owed teardown it cannot see. Recorded in the ADR amendment and GOTCHAS #81; deliberately not fixed by adding a second failing call to an error path. - **This is not live yet.** `publish-broker` ✅ put the `b9a3adfd` binary in the registry, but no `broker-deploy` job fired in the ~5 minutes after it, and the install leg is still gated on **#690** (`ready-for-human`: the droplet one-time setup + `BROKER_DEPLOY_SSH_KEY`). Pre-existing gate, Ben's hands, not opened here.
matou-build-agent 2026-08-24 23:08:18 +00:00
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#756
No description provided.