Public: anyone can read this; the crew can change it.

Sentinel: cloud-watch:digitalocean/prod was degraded 39 minutes today: The forge could not read digitalocean/prod to check it for stray machines (no answer in time); it is not known to be cl… #17861

opened this

Merged 29h 45m ago, live in production

When one DigitalOcean list read hung past the 30-second fetch limit, the whole cloud-watch reading failed. The duty then waited an hour before looking again, so /health showed cloud-watch:digitalocean/prod as degraded for up to an hour over a few seconds of trouble at the provider. This change fixes both halves.

Notes

opened this

When one DigitalOcean list read hung past the 30-second fetch limit, the whole cloud-watch reading failed. The duty then waited an hour before looking again, so /health showed cloud-watch:digitalocean/prod as degraded for up to an hour over a few seconds of trouble at the provider. This change fixes both halves.

What changed

  • Each page gets three tries (src/cloud/watch.ts, pages). Each try waits at most 10 s (PAGE_TRY_MS), with a 0.5 s and then a 1 s pause between tries. Only no answer in time, a dropped connection, 429 or 5xx is asked again. A 401, 403 or 404 is the real answer and is reported at once. A failure on every try reads as before ("no answer in time"). This also helps the other callers of pages in src/cloud/projects.ts.
  • A failed reading is taken again after 5 minutes, not the hour (src/maintain/duties/cloud_watch.ts). The duty now has a dueNow: it is due early when a watched account's last reading failed at least RETRY_MS (5 min) ago. It also waits until 5 minutes after the duty's own last start, so an account whose credential won't open can't make it run every tick. The health sentence now says "It looks again within 6 minutes."
  • The duty gets its own 5-minute timeout. Three lists of three 10-second tries don't fit the runner's 30-second default.
  • Its run budget goes from 30 to 120 a day, with the reason updated: room for about 8 hours of a provider not answering. These are read-only calls and cost nothing.
  • Docs: docs/features/cloud.md describes the tries and the retry.

What I chose not to do: hide a failed reading or wait for two in a row before reporting it. A provider that can't be read still raises the /health card at once. It just stands for minutes now, not the hour.

Reused: the runner's existing dueNow hook (as daily_proof uses it), lastStarted from src/maintain/runs.ts, and lastReading. No new dependency.

Tests:

  • test/cloud-watch-read.test.ts: a timed-out page is asked again and the list is read whole; a 503 is tried three times with 500 ms then 1000 ms pauses, then reported; a timeout on every try gives "no answer in time"; a 401, 403 or 404 is not retried.
  • test/cloud-watch.test.ts: the duty is not due just under 5 minutes after a failure and is due at 5 minutes; a recent duty start holds it back; the new sentence; the try budget fits the duty's timeout; a clean reading stops the early runs.

Checks run: bun x tsc --noEmit is clean and the gate is green. The cloud-watch, cloud-projects, cloud-gate, maintain, vitals, notify, unused-exports and fetch-timeout suites pass. scripts/fast.ts named 510 files (about 36 minutes), so I picked the suites myself. A wider batch I started never finished: its tests were trying hosts the sandbox refuses (alpha--localhost, kid--localhost, homie--forge.test), so I have no result from it. The forge's full check covers it.

How to see it in production: after this is live, cloud-watch:digitalocean/prod should leave the degraded list within about 6 minutes of a failed read, or never appear for a single slow page.

🤖 Generated with Claude Code

Closes #17853

commented

When one DigitalOcean list read hung past the 30-second fetch limit, the whole cloud-watch reading failed. The duty then waited an hour before looking again, so /health showed cloud-watch:digitalocean/prod as degraded for up to an hour over a few seconds of trouble at the provider. This change fixes both halves.

What changed

  • Each page gets three tries (src/cloud/watch.ts, pages). Each try waits at most 10 s (PAGE_TRY_MS), with a 0.5 s and then a 1 s pause between tries. Only no answer in time, a dropped connection, 429 or 5xx is asked again. A 401, 403 or 404 is the real answer and is reported at once. A failure on every try reads as before ("no answer in time"). This also helps the other callers of pages in src/cloud/projects.ts.
  • A failed reading is taken again after 5 minutes, not the hour (src/maintain/duties/cloud_watch.ts). The duty now has a dueNow: it is due early when a watched account's last reading failed at least RETRY_MS (5 min) ago. It also waits until 5 minutes after the duty's own last start, so an account whose credential won't open can't make it run every tick. The health sentence now says "It looks again within 6 minutes."
  • The duty gets its own 5-minute timeout. Three lists of three 10-second tries don't fit the runner's 30-second default.
  • Its run budget goes from 30 to 120 a day, with the reason updated: room for about 8 hours of a provider not answering. These are read-only calls and cost nothing.
  • Docs: docs/features/cloud.md describes the tries and the retry.

What I chose not to do: hide a failed reading or wait for two in a row before reporting it. A provider that can't be read still raises the /health card at once. It just stands for minutes now, not the hour.

Reused: the runner's existing dueNow hook (as daily_proof uses it), lastStarted from src/maintain/runs.ts, and lastReading. No new dependency.

Tests:

  • test/cloud-watch-read.test.ts: a timed-out page is asked again and the list is read whole; a 503 is tried three times with 500 ms then 1000 ms pauses, then reported; a timeout on every try gives "no answer in time"; a 401, 403 or 404 is not retried.
  • test/cloud-watch.test.ts: the duty is not due just under 5 minutes after a failure and is due at 5 minutes; a recent duty start holds it back; the new sentence; the try budget fits the duty's timeout; a clean reading stops the early runs.

Checks run: bun x tsc --noEmit is clean and the gate is green. The cloud-watch, cloud-projects, cloud-gate, maintain, vitals, notify, unused-exports and fetch-timeout suites pass. scripts/fast.ts named 510 files (about 36 minutes), so I picked the suites myself. A wider batch I started never finished: its tests were trying hosts the sandbox refuses (alpha--localhost, kid--localhost, homie--forge.test), so I have no result from it. The forge's full check covers it.

How to see it in production: after this is live, cloud-watch:digitalocean/prod should leave the degraded list within about 6 minutes of a failed read, or never appear for a single slow page.

🤖 Generated with Claude Code

commented

While this pull waited, main already fixed the same problem for the hetzner twin of this issue (#17859). The merge keeps main's fix as it is and drops this branch's copy. This pull now adds only what main was missing: a guard against a fast-retry loop, a correct health sentence, and the matching docs.

What main already does (src/cloud/watch.ts, src/maintain/duties/cloud_watch.ts):

  • Page retries: up to three tries of 15 s, 5 s and 15 s apart, on no answer in time, no connection, or a 429/502/503/504. Any other answer is reported at once.
  • Faster second look: a failed reading is read again after 10 minutes instead of waiting for the next hourly run.
  • Duty limits: a 10-minute timeout for the duty and room for 60 runs a day.

What this pull adds on top:

  • Guard on the fast second look: it waits at least 10 minutes after the duty's last start. Without this, an account whose credential won't open keeps its failed reading, so on main the duty would run every minute until its daily budget ran out.
  • Correct sentence: the /health sentence promised "It looks again within the hour", which stopped being true once main added the 10-minute second look. It now says "It looks again within ten minutes."
  • Docs: docs/features/cloud.md describes the retries and the 10-minute second look.
  • Tests: test/cloud-watch.test.ts checks that a recent duty start holds the second look back and lets it through 10 minutes later, and that the sentence says "within ten minutes".

Checks run: bun x tsc --noEmit and the gate are clean. The cloud-watch, cloud-projects, maintain-duty-states and unused-exports suites pass (39 tests). I picked these myself rather than running the whole suite.

How to see it in production: after a failed read of digitalocean/prod, its /health card should clear within about ten minutes once the provider answers again, not stay for the hour.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs