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

Recovery, part 2: snapshots are mirrored off the box within the hour, and a stale mirror is a board line and a push #1992

Parked opened this
Closed without merging

Every snapshot is now copied to a second S3-compatible bucket, and a failing or day-stale mirror shows as one board line and one push. bun x tsc --noEmit is clean. I ran test/check-list.test.ts, the new mirror test and the existing snapshot, drill, vitals and notify tests: 80 pass, 2 fail.

Notes

stopped parked by the crew deploy 20620dd

opened this

Every snapshot is now copied to a second S3-compatible bucket, and a failing or day-stale mirror shows as one board line and one push. bun x tsc --noEmit is clean. I ran test/check-list.test.ts, the new mirror test and the existing snapshot, drill, vitals and notify tests: 80 pass, 2 fail. Both failures are in test/snapshot-destination.test.ts and fail the same way with my changes stashed:

  • a failed test-connection is one sentence and leaks no key
  • the page says a snapshot is being taken, even before there is a first one

I did not chase them.

What changed

  • Mirror module (src/snapshot/mirror.ts): a pass copies the newest 14 snapshots the mirror lacks. The manifest goes last, so a half-copied snapshot is never listed. Objects already there are skipped, so an interrupted pass resumes. Then it prunes the mirror to 14. What the pass found is kept in mirror/state.json under the data directory, so the board and the push read it without network.
  • Schedule (src/snapshot/service.ts): a pass runs right after each snapshot, 30 s after boot, and every hour. mirrorNow() and mirrored() are on the snapshots handle, and a mirror failure never fails the snapshot.
  • Keys: sealed like the Backups destination (SNAPSHOT_MIRROR_S3_*, write-only, set on the Backups page), or FORGE_MIRROR_S3_* in the environment.
  • Backups page: a new "Off-box mirror" card shows reachability, the newest mirrored snapshot, when it was last confirmed level, and any failing line. It has Seal, Mirror now and Clear buttons on three new admin POST routes under /settings/backups/mirror.
  • Board and push: a pass that failed (mirror unreachable, or "snapshot X did not land") or a mirror not confirmed level for 24 h is the board's mirror card. The admin gets one push per cause through the same path as the red restore drill line (#1804). A repeat tick is not a second push.
  • Other edits: s3Store takes optional retry options so tests can fail fast. The new test file is in GATE in scripts/gate.ts. docs/SNAPSHOT.md has an "Off-box mirror" section. There is no migration, and no dependency was added.

Tests

  • test/snapshot-mirror.test.ts: six tests against a stand-in S3 on a loopback port.
    • A snapshot lands in both buckets, byte for byte.
    • An unreachable mirror gives one board line and one push.
    • A recovered mirror catches up and the line clears.
    • A snapshot that failed mid-copy names itself and is not listed.
    • A mirror stale past a day gives a line.
    • Mirror resolution from the environment.
  • Sandbox proxy: Bun.S3Client is refused by this sandbox's proxy even on loopback, so I ran the S3 tests with the *_PROXY variables unset. The forge's check should not hit this.

Left out

  • Copy, not parallel write: the mirror is copied from the primary store, not written to in parallel. A snapshot that never landed on the primary is not seen by the mirror.
  • Staleness clock: "older than a day" counts from the last confirmed-level pass, not the snapshot's own age. Counting from the snapshot would trip every morning while the 08:00 snapshot is still running.
  • Mirror test button: there is none; "Mirror now" runs a pass and reports the result.
  • Restore from the mirror: no command reads from it yet. Today you point the restore at the mirror by exporting its bucket as S3_*.

Try it

  • Set the FORGE_MIRROR_S3_* variables, or seal a bucket at /settings/backups.
  • Press "Snapshot now", then "Mirror now".
  • Block the mirror and the board shows the line.

Closes #1987

commented

Parked by the crew: the check failed ("the off-box mirror > a snapshot lands in both buckets, and the page's facts say so") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs