Skip to content

feat(ci): seed the RAM pool's golden workspace from the NVMe golden as its own maintenance kind - #5498

Draft
shepherdjerred wants to merge 4 commits into
ci-ram-workspace-routefrom
ci-ram-golden-seed
Draft

shepherdjerred wants to merge 4 commits into
ci-ram-workspace-routefrom
ci-ram-golden-seed

Conversation

@shepherdjerred

Copy link
Copy Markdown
Owner

Why

RAM workspaces clone a golden workspace that must live in the RAM pool, because ZFS clones only within a pool. That golden must be seeded, refreshed whenever the NVMe golden refreshes, and re-seeded after every reboot, which empties the pool. A RAM problem must never block the NVMe golden refresh.

PR 3 of 5.

What

  • New CI maintenance kind workspace-golden-ram, separate from workspace-golden:
    • Candidate: an INFRA activity reads the selected NVMe golden and the ci-workspace-route state. It offers a candidate only when an NVMe golden is selected and the pool is ONLINE. The fingerprint is <NVMe snapshot>@<pool GUID>, so the RAM golden re-seeds exactly when the NVMe golden changes or the pool is recreated.
    • Claim: before submitting, ensureCiWorkspaceGoldenRamClaim makes sure the Temporal-owned PVC woodpecker-workspace-golden-ram exists on ci-golden-ram, 12Gi, annotated with the live pool GUID. A claim from an earlier pool generation is deleted, its removal waited out with heartbeats, and the claim recreated. ArgoCD could not repair it after a reboot.
    • Pipeline: step maintenance-workspace-golden-ram syncs the published NVMe golden tree into the live RAM tree in place (syncTree: rsync -aH --numeric-ids --delete --chown=1000:1000, the CI base image ships rsync): changed files (by size and mtime) are rewritten, extraneous ones deleted, modes, symlinks and hard links kept, matching files untouched. The old marker is removed first and the new one written last, then Temporal snapshots the claim. It fails loudly without the NVMe marker. Leftover .staging/.retired trees from the earlier approach are removed.
    • Why in place (arithmetic in publish-workspace-golden-ram.ts): the claim's 12Gi ZFS quota counts its snapshots, so it must hold the live tree G plus what the retained snapshots alone hold, about the delta D between refreshes. At zstd-1/ashift 12 (PR 1's sizing): G = 4.66 GiB, D = 1.40 GiB (the 1.3x turnover). In place: G + D = 6.06 GiB steady, G + 2D = 7.46 GiB during a reseed until the oldest retained snapshot is pruned. The old staging swap shares no blocks with the snapshot of the tree it replaces: about 2G + D = 10.72 GiB transiently, 1.3 GiB under the quota.
    • Snapshot: a shared, parameterized publisher snapshots it (ci-workspace-golden-ram-…, 12Gi, its own label) and selects it in ci-workspace-golden-ram as {snapshot, restoreSize: "12Gi", poolGuid}. It retains the selected snapshot and its predecessor, as NVMe does, and never prunes a RAM snapshot that a Pending or Bound claim in woodpecker-ci names as dataSource/dataSourceRef: a RAM claim admitted just before a reseed's selection swap is provisioned from the snapshot it was given, and would hang if that snapshot were deleted first. The infra role gains list on PVCs. NVMe pruning excludes the RAM prefix and does not list claims.
    • Workflow: the coordinator's new calls are guarded by patched("ci-maintenance-golden-ram-v1"). A RAM claim failure hands the tick to the other kinds. A RAM publish is abandoned if the pool was recreated in between, and RAM seeding waits while an NVMe snapshot is pending.
  • ci-pod-guard: the RAM step may mount both golden claims. The RAM golden claim is otherwise mountable only by that step, on main and manual. The RAM step mounts the NVMe golden read-only: a new MutatingAdmissionPolicy woodpecker-workspace-golden-ram-reader.sjer.red, scoped by matchConditions to pods whose step key is maintenance-workspace-golden-ram and that mount woodpecker-workspace-golden, rewrites those container and init-container mounts to readOnly: true (mirroring the workspace-seeds policy's readerMounts; the CSI volume itself stays RW for ZFS), and the pod guard refuses that step if any such mount is still writable. Temporal RBAC grows to cover the RAM ConfigMap, the route ConfigMap and the RAM claim.
  • ci-workspace-reaper reaps leaked ci-workspace-ram claims under the same age and terminal-pod rules as ci-workspace ones (not the Temporal-owned RAM golden claim), and WoodpeckerWorkspaceClaimLeaked matches both classes.
  • Toolkit maintenance classification, retry kinds and the scorecard know the new kind. The ops blocked-signal schema pages on it.
  • Docs: wiki CI admission, the extension and Temporal READMEs, the toolkit README.

Demo

Seeding is proven in tests (ci-workspace-golden-ram.test.ts, maintenance-golden-ram.test.ts):

  1. Candidate: appears only with a selected NVMe golden and an ONLINE pool (ready, full or seeding). Its fingerprint changes with the pool GUID or the NVMe snapshot. Nothing is touched while the pool is absent.
  2. Claim: a claim with a stale or missing GUID is deleted, waited out, and recreated on the live pool.
  3. Takeover: a history recorded by a frozen copy of the pre-change coordinator replays on the new code. The new code then takes over the same execution, seeds, and selects the RAM snapshot with its pool GUID. It does not reseed the same fingerprint, and it does reseed after a GUID change. With the patch guard removed, the same replay fails with a nondeterminism error (submitCiMaintenance vs inspectCiWorkspaceGoldenRam).
  4. NVMe unchanged: existing golden tests pass unmodified, NVMe still writes {snapshot, restoreSize: "32Gi"} and never prunes a RAM snapshot, and a failing RAM claim hands the tick to the NVMe refresh.
  5. Retention: a RAM publish keeps its predecessor and deletes only older, unreferenced snapshots; a snapshot a Pending, Bound or phase-less claim clones is spared however old (a Lost claim, a non-snapshot source and a foreign API group are ignored).
  6. In-place sync (golden-sync.test.ts, real rsync): an unchanged file keeps its inode and mtime, a changed file is rewritten with its new mtime, extraneous files and directories are deleted while the target's marker is neither copied nor deleted, symlinks (including dangling) stay links, hard links stay one inode, a link replaced by a file becomes a file, and an rsync failure throws.
  7. Live history replay (read-only): the live ci-maintenance-coordinator history (704 events, exported with toolkit temporal workflow show -o json) replays cleanly under this branch's workflows.

Verification

  • Required before merge (operator): the server-side dry-run compile check from the liskov README ("Compile the admission policies before merging a change to them"), run at this branch's head. This PR changes woodpecker-ci-pod-guard, which every CI pod passes through (one golden-claim mount rule now allows two step keys, a new rule for the RAM golden claim, and the read-only rule for the RAM step), and adds the woodpecker-workspace-golden-ram-reader mutation.
  • bunx turbo run build typecheck test lint --filter=@homelab/cdk8s --filter=@shepherdjerred/temporal --filter=@shepherdjerred/woodpecker-config-extension --filter=@shepherdjerred/toolkit: 49/49, on the restacked base.
  • bun run check-ci-admission-budget: holds. bunx turbo run jscpd quality-ratchet knip --filter=//: pass. bunx lefthook run pre-commit: pass.
  • bun run verify:extended -- --filter='...[origin/main...HEAD]': 72/72 at the pre-rebase stack top (ce27b2e17e); to be re-run on the final heads before any PR is marked ready.
  • Not run:
    • live seeding;
    • ci/scripts/publish-workspace-golden-ram.ts itself, which needs the claim mounts;
    • whether the golden tree plus a retained snapshot fits 12Gi live;
    • the pod-guard CEL, which is checked as text.
  • The hand-written replay fixture stays. The exported live history replays (above) but is not committed as the fixture: every one of its 64 ticks failed in inspectCiMaintenance ("GitHub source tree was truncated"), so it never reaches candidate selection where the patch guard matters, and an exported history cannot seed the takeover half of the test.

🤖 Generated with Claude Code

shepherdjerred and others added 4 commits November 28, 2026 15:03
…s its own maintenance kind

Why
RAM workspace claims can only clone a snapshot in the RAM pool, and the route
publisher reports `seeding` until `ci-workspace-golden-ram` names a 12Gi RAM
snapshot taken on the live pool. Nothing produced one. The pool and its
datasets vanish on every reboot, and a RAM golden goes stale with every NVMe
golden refresh, so the seed must repeat exactly then, and a RAM problem must
never hold back the NVMe golden refresh every workspace depends on.

What
- New maintenance kind `workspace-golden-ram`. Whenever the `workspace-golden`
  candidate exists, an infra read proposes a RAM seed at its verified source
  when `ci-workspace-golden` names an NVMe snapshot and `ci-workspace-route`
  reports an ONLINE pool (ready, full or seeding). The fingerprint is
  `<nvme snapshot>@<pool GUID>`, so it changes on each NVMe refresh and each
  reboot.
- Before submitting it, `ensureCiWorkspaceGoldenRamClaim` makes the
  Temporal-owned claim `woodpecker-workspace-golden-ram` (ci-golden-ram, 12Gi,
  RWX, backup disabled) carry the live pool GUID, deleting and awaiting a claim
  from an earlier pool first. A failed read or claim leaves the RAM kind out
  of that tick and the coordinator submits the next kind instead.
- After the pipeline succeeds, the RAM claim is snapshotted as
  `ci-workspace-golden-ram-<source12>-<req8>` and selected with
  `{snapshot, restoreSize: 12Gi, poolGuid}`, keeping only the selected
  snapshot. A claim from an earlier pool abandons the publication so the next
  tick seeds the new pool. NVMe and RAM share one parameterized snapshot
  publisher; NVMe names, 32Gi, two retained snapshots and `{snapshot,
  restoreSize}` are unchanged, and NVMe pruning ignores RAM snapshots.
- The coordinator guards all three new activity calls with patch
  `ci-maintenance-golden-ram-v1`. A frozen pre-change coordinator fixture
  records the history the replay test feeds the new code.
- Extension: `maintenance-workspace-golden-ram` mounts both golden claims and
  runs `ci/scripts/publish-workspace-golden-ram.ts`, which copies the published
  NVMe golden tree with the same staging swap, chown and marker, and fails when
  the NVMe marker is missing. Requests need the verified main source like the
  other workspace kinds.
- Homelab: the CI pod guard lets the RAM seed mount the NVMe golden and only
  the RAM seed (main, manual) mount the RAM golden; the infra worker's golden
  Role gains the RAM ConfigMap, the route read, PVC create and get/delete of
  the RAM claim; the PVC backup policy classifies the RAM claim.
- Ops signals page on a blocked RAM kind; toolkit classifies, lists and
  retries it.
- Docs: wiki ci-admission explains the seed, its re-seeding and the claim's
  ownership; extension, Temporal and toolkit READMEs describe the kind.

Verification
- bunx turbo run build typecheck test lint --filter=@shepherdjerred/temporal
  --filter=@shepherdjerred/woodpecker-config-extension --filter=@homelab/cdk8s
  --filter=@shepherdjerred/toolkit --continue: 49/49 tasks pass.
- Workflow tests (Node): a coordinator recorded by the frozen pre-change
  fixture replays on the new code, then the new code takes over the same
  execution, seeds the RAM golden (inspect, ensure claim, submit), selects its
  snapshot, does not reseed the same fingerprint, and reseeds after a pool
  GUID change; history carries one `ci-maintenance-golden-ram-v1` marker and
  replays. Without the patch guard the fixture replay fails with
  "Activity type of scheduled event 'submitCiMaintenance' does not match
  activity type of activity command 'inspectCiWorkspaceGoldenRam'". A failing
  claim ensure hands the tick to the NVMe golden refresh.
- Activity tests: the RAM candidate exists only with an NVMe golden and an
  ONLINE pool, and its fingerprint changes with the GUID or NVMe snapshot; a
  claim with a stale or missing GUID is deleted, awaited and recreated, and
  nothing is touched while the pool is absent; a seeded claim is selected with
  `{snapshot, restoreSize: "12Gi", poolGuid}` and every other RAM snapshot is
  pruned; a claim from an earlier pool abandons the publish. NVMe publication
  still writes `{snapshot, restoreSize: "32Gi"}` and never prunes a RAM
  snapshot; existing NVMe golden tests pass unchanged.
- bun run check-ci-admission-budget: holds for 61 generated steps.
- bunx turbo run jscpd quality-ratchet knip --filter=//: 16/16 pass.
- bunx lefthook run pre-commit: pass.
- Not run: live seeding (no Temporal, Woodpecker or cluster writes),
  retained-production-history replay, the extended tier (verify:extended), and
  the RAM publisher script itself (it needs the /woodpecker claim mounts). The
  NVMe golden mount is read-write: the step volume model has no read-only
  option. The pod guard CEL is checked as text, not evaluated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… golden in place, and reap leaked RAM workspaces

Why
A RAM claim admitted just before a reseed's selection swap is provisioned
from the snapshot it was given, but the RAM golden kept only the selected
snapshot, so that snapshot could be deleted under it and the claim would hang.
The workspace reaper and its leak alert knew only the ci-workspace class, so a
leaked RAM workspace would hold liskov memory indefinitely. The seed rebuilt a
full copy beside the live tree, which shares no blocks with the snapshot of the
tree it replaces, and it mounted the NVMe golden every workspace clones
read-write.

What
- RAM_GOLDEN retains the selected snapshot and its predecessor, as NVMe does,
  and never prunes a snapshot a Pending, Bound or phase-less claim in
  woodpecker-ci names as dataSource or dataSourceRef. The infra role gains list
  on PVCs; the NVMe golden does not list claims.
- ci-workspace-reaper reaps ci-workspace-ram claims under the same age and
  terminal-pod rules, and WoodpeckerWorkspaceClaimLeaked matches both classes.
- The RAM seed syncs the NVMe golden into the live RAM tree in place
  (syncTree: rsync -aH --numeric-ids --delete --chown=1000:1000, which the CI
  base image ships), unmarked while it changes, marker written last, then
  Temporal snapshots it. The 12Gi quota counts snapshots: in place it holds
  G + D = 6.06 GiB steady and G + 2D = 7.46 GiB during a reseed, against
  about 2G + D = 10.72 GiB for the old staged copy (G = 4.66 GiB, D = 1.40
  GiB at zstd-1 and ashift 12).
- MutatingAdmissionPolicy woodpecker-workspace-golden-ram-reader.sjer.red,
  matched to pods whose step key is maintenance-workspace-golden-ram, makes
  their mounts of woodpecker-workspace-golden read-only, mirroring the
  workspace-seeds readerMounts; the pod guard refuses that step otherwise.
  Cluster-baseline admission inventory and the pvc-backup-policy admission
  counts include it.
- Docs: wiki CI admission and workflow families, the Temporal and extension
  READMEs.

Verification
- bun vitest (packages/temporal) src/activities/maintenance and
  src/activities/homelab/zfs-maintenance.test.ts: 30 files, 321 tests pass,
  including retention, referenced-snapshot and RAM reaper tests.
- bun vitest (packages/woodpecker-config-extension)
  test/checkout/golden-sync.test.ts and test/maintenance.test.ts: pass; the
  sync tests run real rsync for unchanged, changed, deleted, symlink and hard
  link cases.
- bun run scripts/run-test.ts (packages/homelab/src/cdk8s) ci-namespace,
  ci-workspace-golden-rbac, cluster-baseline, backup-policy and woodpecker
  rules: 5 files, 63 tests pass.
- bunx turbo run typecheck lint for @homelab/cdk8s, temporal,
  woodpecker-config-extension and root-scripts: 43/43.
- Read-only: the live ci-maintenance-coordinator history (704 events, via
  toolkit temporal workflow show) replays under this branch's workflows. It
  is not committed as the replay fixture: every tick failed in
  inspectCiMaintenance, so it never reaches the patched candidate path.
- bunx lefthook run pre-commit: pass.
- Not run: the server-side dry-run compile of the new mutation and guard
  rule, and a live reseed; no live change was made.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cies from one helper

Why
The RAM golden reader mutation copied the workspace-seeds mutation's shape,
which the jscpd ratchet rejects as new duplication.

What
- createReaderMountPolicy builds the MutatingAdmissionPolicy and binding from
  an id, name, match conditions and the CEL variable naming the volumes; the
  workspace-seeds and RAM golden reader policies both use it.

Verification
- The pod guard chart synthesizes byte-identical YAML before and after.
- bun run scripts/run-test.ts ci-namespace and cluster-baseline
  (packages/homelab/src/cdk8s): 2 files, 33 tests pass; eslint and tsc
  --noEmit pass.
- bunx lefthook run pre-commit: pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s models

Why
main adopted typescript-eslint 8.74 (#5165), whose
no-unsafe-class-instance-assignment rule rejects plain objects passed where
a Kubernetes client model is expected. The RAM golden snapshot-reference
test, rebased onto main, built its claims as object literals and failed the
temporal lint.

What
- The claims in the snapshot-reference test are built with model(), as main's
  other Kubernetes tests are, including their spec, data source and status.

Verification
- bunx eslint src/activities/maintenance (packages/temporal): clean.
- bun vitest src/activities/maintenance/ci-workspace-golden.test.ts: 10 pass.
- tsc --noEmit (packages/temporal): no errors outside the unrelated
  ungenerated artifacts client.
- bunx lefthook run pre-commit: pass.
- Not run: any live check; test-only change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Automatic reviews are disabled for this repository. Configure in Code Review Settings.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant