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

Sentinel: snapshot-failed was degraded 33 minutes today: The last snapshot failed: list chunks/ failed after 5 attempts: an unexpected error has occurred. The newest that lande… #17863

opened this

Merged 32h 30m ago, live in production

scout/forge:scout/17862-sentinel-snapshot-failed-was-degraded-33 → main 0 commits fork 1 thread · 1 unresolved

  • Merged. scout/17862-sentinel-snapshot-failed-was-degraded-33 was merged into main as 5fa2c54.

Review

Sign in to review this change.
3 files changed +45 −6
docs/SNAPSHOT.md +9 −4
@@ -235,10 +235,15 @@ The terminal has no backups view, so it has no readout.
235235 ## When a snapshot fails
236236
237237 Its outcome is kept in `snapshot/state.json` under the data directory, so a
238 restart forgets nothing. A failure shows straight away as a card on the board
239 (`snapshot-failed`, pointing at Backups), in the terminal's dashboard among
240 the forge's needs, and as a red line on the Backups page with the reason and
241 since when. The forge tries again after ten minutes (`SNAPSHOT_RETRY_MS`, capped at the
238 restart forgets nothing. A failure shows straight away as a red line on the
239 Backups page with the reason and since when. The card on the board
240 (`snapshot-failed`, pointing at Backups) and the terminal's dashboard needs
241 wait: a failure that clears within an hour (`SNAPSHOT_GRACE_MS`) is a flake,
242 not a card, while the newest snapshot that landed is under 30 hours old
243 (`SNAPSHOT_LEAN_MS`). Past the hour, or when the newest landed is older than
244 that, or when none ever landed, the card shows at once. Only the card and the
245 terminal go through `snapshotNeed`; the Backups line does not wait.
246 The forge tries again after ten minutes (`SNAPSHOT_RETRY_MS`, capped at the
242247 next nightly), not the next night: a store that is down gets six tries an hour, each of five
243248 attempts per put. The
244249 next snapshot that lands, nightly or on demand, clears both.
src/snapshot/outcome.ts +17 −1
@@ -162,11 +162,27 @@ function write(dataDir: string, next: SnapshotOutcome): void {
162162 */
163163 export const SNAPSHOT_RETRY_MS = 10 * 60_000;
164164
165 /** The card a failing snapshot is, or undefined while the last one landed. */
165 /**
166 * A failure that clears within this is a flake, not a card, while a snapshot under
167 * `SNAPSHOT_LEAN_MS` old is still there to lean on (a store's listing erroring for 33 minutes,
168 * 2026-12-03, #17862). Six retries; the backup-late cards cover a store that stays dead.
169 */
170 export const SNAPSHOT_GRACE_MS = 60 * 60_000;
171 /** How old the newest landed snapshot may be for a short failure to stay quiet. */
172 export const SNAPSHOT_LEAN_MS = 30 * 3_600_000;
173
174 /**
175 * The card a failing snapshot is, or undefined while the last one landed, or while the failure is
176 * young and the newest that landed is recent.
177 */
166178 export function snapshotNeed(
167179 s: SnapshotOutcome | undefined,
180 now: number = Date.now(),
168181 ): { sentence: string; since: string } | undefined {
169182 if (s?.failingSince === undefined) return undefined;
183 // Never landed is NaN: the comparison below is false, so the card shows.
outdated

Correct as written: a never-landed snapshot gives NaN, so the comparison is false and the card shows. A one-line comment saying so would help the next reader. The doc in docs/SNAPSHOT.md must be updated to describe this grace; it still says the card shows straight away.

184 const landed = s.landedAt === undefined ? NaN : Date.parse(s.landedAt);
185 if (now - Date.parse(s.failingSince) < SNAPSHOT_GRACE_MS && now - landed < SNAPSHOT_LEAN_MS) return undefined;
170186 const last = s.landedAt ? ` The newest that landed is from ${s.landedAt.slice(0, 10)}.` : "";
171187 return {
172188 sentence: `The last snapshot failed: ${(s.error ?? "unknown reason").replace(/\.$/, "")}.${last} The forge tries again in ${SNAPSHOT_RETRY_MS / 60_000} minutes.`,
test/snapshot-outcome.test.ts +19 −1
@@ -14,7 +14,7 @@ import { forgeNeeds, forgeVitals } from "../src/actions/health.ts";
1414 import { createApp, type App } from "../src/app.ts";
1515 import { createUser, type User } from "../src/core/users.ts";
1616 import { serve, type Servers } from "../src/http/server.ts";
17 import { lastSnapshotOutcome, recordSnapshotOutcome, snapshotNeed, SNAPSHOT_RETRY_MS } from "../src/snapshot/outcome.ts";
17 import { lastSnapshotOutcome, recordSnapshotOutcome, snapshotNeed, SNAPSHOT_GRACE_MS, SNAPSHOT_RETRY_MS } from "../src/snapshot/outcome.ts";
1818 import { startSnapshots } from "../src/snapshot/service.ts";
1919 import { dirStore, type Store } from "../src/blob/store.ts";
2020
@@ -46,6 +46,24 @@ describe("the outcome kept", () => {
4646 });
4747 });
4848
49 describe("a flake the next try clears (#17862)", () => {
50 const dir = mkdtempSync(join(tmpdir(), "forge-flake-"));
51 const t0 = Date.parse("2026-12-03T08:36:00.000Z");
52 test("is no card inside the grace while a recent snapshot landed, and is one after it", () => {
53 recordSnapshotOutcome(dir, { landed: "2026-12-02T08-00-00Z" }, "2026-12-02T08:40:00.000Z");
54 recordSnapshotOutcome(dir, { error: "list chunks/ failed after 5 attempts" }, new Date(t0).toISOString());
55 const o = lastSnapshotOutcome(dir);
56 expect(snapshotNeed(o, t0 + 33 * 60_000)).toBeUndefined();
57 expect(snapshotNeed(o, t0 + SNAPSHOT_GRACE_MS + 1)?.since).toBe(new Date(t0).toISOString());
58 });
59 test("is a card at once when the newest landed is old", () => {
60 const d2 = mkdtempSync(join(tmpdir(), "forge-flake-"));
61 recordSnapshotOutcome(d2, { landed: "2026-11-30T08-00-00Z" }, "2026-11-30T08:40:00.000Z");
62 recordSnapshotOutcome(d2, { error: "x" }, new Date(t0).toISOString());
63 expect(snapshotNeed(lastSnapshotOutcome(d2), t0 + 60_000)).toBeDefined();
64 });
65 });
66
4967 describe("a nightly that fails", () => {
5068 let root: string;
5169 let app: App;

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

Keyboard shortcuts

Docs