Consolidate DigitalOcean transient-5xx retries into one provider-boundary policy #753

Closed
opened 2026-08-24 19:01:04 +00:00 by matou-build-agent · 3 comments

Symptom / context

Filed from #752. Over one evening, three DigitalOcean transient-5xx call-sites each cost a full drive + a ticket + a #720 red-streak reset: #749 (Destroy DELETE, 504), #751 (LatestImageID snapshot-list GET, 500), #752 (the same GET, a sustained 500).

Ben's steer on #752 (ruled by agent under ADR 0174 — veto anytime):

Rather than a third per-call patch, consider closing the CLASS: wrap the provider's DigitalOcean API surface in one shared bounded-retry policy (transient 5xx/429 → short exponential backoff, ~3 attempts, loud log line per retry; 4xx and permanent errors excluded so real refusals still fail fast — the #682 'errored create' lesson means a create that RETURNS but errors is NOT retried by this, only transport-level 5xx). Lifting it to the provider boundary means the next flaky endpoint (snapshot list, tag ops, actions log…) never files #753.

Proposed fix

Consolidate the ad-hoc per-call retries (doRetryTransient #749/#751, ensureSSHKey #677's POST retry, pollActive #672's read-after-write) into one shared bounded-retry policy at the DigitalOcean provider boundary (broker/internal/broker/provider_do.go):

  • transient class only: transport errors + 5xx (500/502/503/504) + 429; short exponential backoff, ~3 attempts, one loud log line per retry;
  • 4xx and permanent errors excluded (real refusals still fail fast);
  • the droplet-create POST stays un-retried even at transport level — a 5xx may hide a droplet that WAS created, so a blind retry leaks a box (ADR 0047 / #682). The policy must make this exclusion explicit, not accidental.

Then the next flaky endpoint (tag ops, actions log, …) is covered without a new per-call ticket.

Scope note

This is a forward-looking refactor, NOT the fix for #752's red. #752's image call was already wrapped by #751; it red anyway because the outage was sustained past the fixed budget. #752 closed that red by decoupling the rehearsal-rentfail provision fault from the image lookup (a fixed retry budget can't outlast an arbitrarily long outage). This ticket is the separate class-closing cleanup Ben asked to track.

Found while working

#752 (rent-fails-clean: DO 500 on image lookup pre-empts the provision-fault assertion).

## Symptom / context Filed from #752. Over one evening, **three** DigitalOcean transient-5xx call-sites each cost a full drive + a ticket + a `#720` red-streak reset: #749 (Destroy DELETE, 504), #751 (LatestImageID snapshot-list GET, 500), #752 (the same GET, a *sustained* 500). Ben's steer on #752 (ruled by agent under ADR 0174 — veto anytime): > Rather than a third per-call patch, consider closing the CLASS: wrap the provider's DigitalOcean API surface in one shared bounded-retry policy (transient 5xx/429 → short exponential backoff, ~3 attempts, loud log line per retry; 4xx and permanent errors excluded so real refusals still fail fast — the #682 'errored create' lesson means a create that RETURNS but errors is NOT retried by this, only transport-level 5xx). Lifting it to the provider boundary means the next flaky endpoint (snapshot list, tag ops, actions log…) never files #753. ## Proposed fix Consolidate the ad-hoc per-call retries (`doRetryTransient` #749/#751, `ensureSSHKey` #677's POST retry, `pollActive` #672's read-after-write) into **one shared bounded-retry policy at the DigitalOcean provider boundary** (`broker/internal/broker/provider_do.go`): - transient class only: transport errors + 5xx (500/502/503/504) + 429; short exponential backoff, ~3 attempts, one loud log line per retry; - 4xx and permanent errors excluded (real refusals still fail fast); - the **droplet-create POST stays un-retried** even at transport level — a 5xx may hide a droplet that WAS created, so a blind retry leaks a box (ADR 0047 / #682). The policy must make this exclusion explicit, not accidental. Then the next flaky endpoint (tag ops, actions log, …) is covered without a new per-call ticket. ## Scope note This is a **forward-looking refactor**, NOT the fix for #752's red. #752's image call was *already* wrapped by #751; it red anyway because the outage was **sustained** past the fixed budget. #752 closed that red by **decoupling** the `rehearsal-rentfail` provision fault from the image lookup (a fixed retry budget can't outlast an arbitrarily long outage). This ticket is the separate class-closing cleanup Ben asked to track. ## Found while working #752 (rent-fails-clean: DO 500 on image lookup pre-empts the provision-fault assertion).
Author
Member

This was generated by AI during triage.

Verified against the current code: doRetryTransient already exists and wraps several DO call sites (snapshot list, droplet delete, droplet get), but the droplet-create POST correctly stays on the un-retried d.do path (per ADR 0047 — a lost response to a successful create must not be retried blind). The ticket's proposed boundary preserves that exclusion explicitly rather than accidentally. Two-way door — refactor consolidating existing retry call sites behind one policy, revertible by commit, provable by extending the existing provider_do_test.go httptest suite — moving to ready-for-agent.

Agent Brief

Category: enhancement
Summary: Consolidate the DigitalOcean provider's ad-hoc per-call transient-retry logic into one shared bounded-retry policy at the provider boundary, so the next flaky endpoint doesn't need its own ticket.

Current behavior:
Transient 5xx/429 handling against the DigitalOcean API is implemented per call site: an existing doRetryTransient helper covers some GETs and the delete call, ensureSSHKey's POST has its own retry, and other call sites have none. Each new flaky endpoint discovered in production has required its own patch and its own incident.

Desired behavior:
One shared retry policy sits at the DigitalOcean provider boundary and is applied uniformly: transient class only (transport errors, 5xx, 429), short exponential backoff, ~3 attempts, one loud log line per retry. Non-transient errors (4xx, permanent failures) are excluded and fail fast. The droplet-create POST is explicitly and permanently excluded from this policy — a 5xx there may mask a droplet that was actually created, and retrying blind risks a double-create (ADR 0047's no-half-rented rule) — the exclusion must be visible in the code, not incidental.

Key interfaces:

  • A single retry-wrapping function (or equivalent) at the provider boundary that every non-create DO call site routes through, replacing the existing per-call-site variations (doRetryTransient and ensureSSHKey's own retry).
  • The droplet-create call path stays on the un-retried call, with a comment or equivalent marker making the exclusion an explicit design choice rather than an oversight.
  • Classification logic: transient (retry) vs. permanent (fail fast) must correctly separate transport-level failures and 5xx/429 from real 4xx refusals — an "errored create that returns" (the #682 lesson) is a create-specific concern, not something this transport-level policy touches.

Acceptance criteria:

  • Every existing DO call site's retry behavior is preserved or improved (no call site becomes less resilient) after consolidation.
  • The droplet-create POST remains un-retried, with the exclusion visible/documented in code.
  • A single point of change handles the next flaky non-create endpoint (e.g. tag ops, actions log) without a new per-call retry implementation.
  • provider_do_test.go (or equivalent) covers: a transient failure that recovers within budget, a transient failure that exhausts budget and fails loud, and a permanent 4xx that is never retried.

Out of scope:

  • Any change to #752's actual fix (the provision-fault decoupling) — this ticket is the separate class-closing cleanup, not a re-fix.
  • Retrying the droplet-create POST under any circumstance — explicitly excluded, not a future TODO for this ticket.
> *This was generated by AI during triage.* Verified against the current code: `doRetryTransient` already exists and wraps several DO call sites (snapshot list, droplet delete, droplet get), but the droplet-create POST correctly stays on the un-retried `d.do` path (per ADR 0047 — a lost response to a successful create must not be retried blind). The ticket's proposed boundary preserves that exclusion explicitly rather than accidentally. Two-way door — refactor consolidating existing retry call sites behind one policy, revertible by commit, provable by extending the existing `provider_do_test.go` httptest suite — moving to `ready-for-agent`. ## Agent Brief **Category:** enhancement **Summary:** Consolidate the DigitalOcean provider's ad-hoc per-call transient-retry logic into one shared bounded-retry policy at the provider boundary, so the next flaky endpoint doesn't need its own ticket. **Current behavior:** Transient 5xx/429 handling against the DigitalOcean API is implemented per call site: an existing `doRetryTransient` helper covers some GETs and the delete call, `ensureSSHKey`'s POST has its own retry, and other call sites have none. Each new flaky endpoint discovered in production has required its own patch and its own incident. **Desired behavior:** One shared retry policy sits at the DigitalOcean provider boundary and is applied uniformly: transient class only (transport errors, 5xx, 429), short exponential backoff, ~3 attempts, one loud log line per retry. Non-transient errors (4xx, permanent failures) are excluded and fail fast. The droplet-create POST is explicitly and permanently excluded from this policy — a 5xx there may mask a droplet that was actually created, and retrying blind risks a double-create (ADR 0047's no-half-rented rule) — the exclusion must be visible in the code, not incidental. **Key interfaces:** - A single retry-wrapping function (or equivalent) at the provider boundary that every non-create DO call site routes through, replacing the existing per-call-site variations (`doRetryTransient` and `ensureSSHKey`'s own retry). - The droplet-create call path stays on the un-retried call, with a comment or equivalent marker making the exclusion an explicit design choice rather than an oversight. - Classification logic: transient (retry) vs. permanent (fail fast) must correctly separate transport-level failures and 5xx/429 from real 4xx refusals — an "errored create that returns" (the #682 lesson) is a create-specific concern, not something this transport-level policy touches. **Acceptance criteria:** - [ ] Every existing DO call site's retry behavior is preserved or improved (no call site becomes less resilient) after consolidation. - [ ] The droplet-create POST remains un-retried, with the exclusion visible/documented in code. - [ ] A single point of change handles the next flaky non-create endpoint (e.g. tag ops, actions log) without a new per-call retry implementation. - [ ] `provider_do_test.go` (or equivalent) covers: a transient failure that recovers within budget, a transient failure that exhausts budget and fails loud, and a permanent 4xx that is never retried. **Out of scope:** - Any change to `#752`'s actual fix (the provision-fault decoupling) — this ticket is the separate class-closing cleanup, not a re-fix. - Retrying the droplet-create POST under any circumstance — explicitly excluded, not a future TODO for this ticket.
Author
Member

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

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

close-report for #753 — status success

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

envelope
{
  "issue": 753,
  "status": "success",
  "commits": [
    "baf1feb2"
  ],
  "changed_files": [
    "STATUS.md",
    "broker/internal/broker/provider_do.go",
    "broker/internal/broker/provider_do_test.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go test ./... (broker/)",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go vet ./internal/broker/ (broker/)",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c golangci-lint run ./internal/broker/ (broker/)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Every existing DO call site's retry behavior is preserved or improved (no call site becomes less resilient)": "provider_do.go: LatestImageID/Destroy/dropletName/deleteSSHKeyByName(GET+DELETE)/Retag(x3)/Exists/ensureSSHKey-POST all route through the shared doRetry engine; Exists+Retag+key-reap gained retry (improved); ensureSSHKey keeps its read-after-write 404 tolerance via isTransientOrUnsettledDO. Existing guards TestDO_LatestImageIDRetriesTransient5xx / DestroyRetriesTransientDeleteGatewayTimeout / EnsureSSHKeyRetriesTransientPostNotFound stay green.",
    "The droplet-create POST remains un-retried, with the exclusion visible/documented in code": "Create() calls raw d.do under an EXPLICIT retry-exclusion comment (provider_do.go ~line 160); new TestDO_CreatePostIsNeverRetried proves a create 5xx is attempted exactly once.",
    "A single point of change handles the next flaky non-create endpoint without a new per-call retry implementation": "One doRetry(ctx,method,path,body,retryable) boundary; new TestDO_ExistsRidesOutTransient5xx shows a previously-un-retried endpoint now rides it with no per-call code.",
    "provider_do_test.go covers a transient failure that recovers within budget, one that exhausts budget and fails loud, and a permanent 4xx that is never retried": "recover-within-budget: TestDO_LatestImageIDRetriesTransient5xx + TestDO_RetriesTransient429; exhaust-budget-fails-loud: TestDO_LatestImageIDFailsLoudWhenSnapshotsNeverRecover / DestroyFailsLoudWhenDeleteNeverRecovers; permanent-4xx-never-retried: TestDO_DestroyDoesNotRetryTerminalRefusal (401)."
  },
  "summary": "Consolidated the DigitalOcean provider's per-call transient retries into one shared bounded-retry policy at the provider boundary, with the droplet-create POST explicitly excluded.",
  "blockers": []
}
**close-report** for #753 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 753, "status": "success", "commits": [ "baf1feb2" ], "changed_files": [ "STATUS.md", "broker/internal/broker/provider_do.go", "broker/internal/broker/provider_do_test.go" ], "tests": [ { "command": "nix develop .#go-ci -c go test ./... (broker/)", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go vet ./internal/broker/ (broker/)", "exit_code": 0 }, { "command": "nix develop .#go-ci -c golangci-lint run ./internal/broker/ (broker/)", "exit_code": 0 } ], "criteria": { "Every existing DO call site's retry behavior is preserved or improved (no call site becomes less resilient)": "provider_do.go: LatestImageID/Destroy/dropletName/deleteSSHKeyByName(GET+DELETE)/Retag(x3)/Exists/ensureSSHKey-POST all route through the shared doRetry engine; Exists+Retag+key-reap gained retry (improved); ensureSSHKey keeps its read-after-write 404 tolerance via isTransientOrUnsettledDO. Existing guards TestDO_LatestImageIDRetriesTransient5xx / DestroyRetriesTransientDeleteGatewayTimeout / EnsureSSHKeyRetriesTransientPostNotFound stay green.", "The droplet-create POST remains un-retried, with the exclusion visible/documented in code": "Create() calls raw d.do under an EXPLICIT retry-exclusion comment (provider_do.go ~line 160); new TestDO_CreatePostIsNeverRetried proves a create 5xx is attempted exactly once.", "A single point of change handles the next flaky non-create endpoint without a new per-call retry implementation": "One doRetry(ctx,method,path,body,retryable) boundary; new TestDO_ExistsRidesOutTransient5xx shows a previously-un-retried endpoint now rides it with no per-call code.", "provider_do_test.go covers a transient failure that recovers within budget, one that exhausts budget and fails loud, and a permanent 4xx that is never retried": "recover-within-budget: TestDO_LatestImageIDRetriesTransient5xx + TestDO_RetriesTransient429; exhaust-budget-fails-loud: TestDO_LatestImageIDFailsLoudWhenSnapshotsNeverRecover / DestroyFailsLoudWhenDeleteNeverRecovers; permanent-4xx-never-retried: TestDO_DestroyDoesNotRetryTerminalRefusal (401)." }, "summary": "Consolidated the DigitalOcean provider's per-call transient retries into one shared bounded-retry policy at the provider boundary, with the droplet-create POST explicitly excluded.", "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.

Dependencies

No dependencies set.

Reference
Matou/idss#753
No description provided.