Repository navigation
feat(homelab): route RAM workspace claims to the RAM pool or, explicitly, to NVMe - #5496
Draft
shepherdjerred wants to merge 4 commits into
Draft
shepherdjerred wants to merge 4 commits into
shepherdjerred wants to merge 4 commits into
Conversation
…tly, to NVMe Why The RAM pool from the previous change needs a storage class, and every RAM workspace claim needs one decision: clone the pool's own golden workspace, or run on NVMe because the pool is absent, unseeded or full. ZFS clones only within a pool, so the NVMe golden cannot serve a RAM claim. Two overlapping full-graph verifies can exceed the 24 GiB pool, so a claim must stop going to RAM before the pool fills, not after. What - Storage classes `ci-workspace-ram` (workspaces) and `ci-golden-ram` (its golden claim), both thin, zstd-1, Delete, liskov only; RAM workspaces are 12Gi, the per-clone quota. - The ci-ram-pool DaemonSet's pool container writes the pool's health, GUID and free space every 15 s; a new unprivileged `ci-ram-pool-route` container turns that and both golden ConfigMaps into `ci-workspace-route`: `ready`, `full` (under the 12Gi quota plus 2 GiB free), `seeding` (no golden for this pool generation, as after every reboot) or `absent` (missing, not ONLINE, or stale). An API error stops the publisher rather than publishing a guess. - One mutating policy routes every unsourced `ci-workspace-ram` claim from that ConfigMap, so no ordering with the NVMe clone policy matters: `ready` clones the RAM golden and labels `ci.sjer.red/workspace-route=ram`; anything else, or a missing ConfigMap, becomes a 32Gi `ci-workspace` claim cloned from the NVMe golden, labelled `nvme-degraded` with a reason annotation. Guards reject a RAM claim that is not a labelled 12Gi RAM-golden clone, and an NVMe claim cloned from a RAM golden. - `CIRamWorkspaceDegraded` fires after 15 minutes of degraded claims. The kube-state-metrics allowlist gains the claim route label and the route ConfigMap's state label, keeping /14's `deployments=` entry: Delivery configuration prometheus/prod/15. - Wiki `ci-admission.md` explains the routing and why the degraded mode is not a silent fallback; the liskov README covers the publisher. Verification - bunx turbo run build typecheck test lint --filter=@homelab/cdk8s --filter=homelab --filter=@shepherdjerred/ops-model: 37/37 pass. - workspace-route.test.ts runs the real publisher script against a fake kubectl: ready; full one byte under 14 GiB (and ready at exactly 14 GiB); seeding after a pool-generation change; absent for missing, stale, MISSING and SUSPENDED status; no NVMe source when none is selected or the name is a RAM golden; an API error exits without applying. - bun run generate:catalog: prometheus/prod/15 differs from /14 only in the kube-state-metrics label allowlist. - bun run check:kubeconform (packages/homelab): 1531 resources, 0 invalid. - bunx lefthook run pre-commit: pass. - Not run: the CEL is checked as rendered text, not evaluated (no local evaluator); the API server compiles it when ArgoCD applies it. No live routing happens until the agents and flag in later changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and track the full share Why Routing a claim to NVMe because the RAM pool is full is routine: at the measured mix about 12% of claims find the pool full. An alert on every degraded claim would fire most of the day. What - Every routed claim also carries `ci.sjer.red/workspace-route-state`, the state it was decided in (ready, full, seeding, absent, or unpublished when no route was published), added in one labels patch when the claim has none. - `ci_workspace:ram_route_claims:count6h` and `ci_workspace:ram_route_share:ratio6h` count each claim once over 6h by state; a share panel sits beside the CI pool writer budgets. - `CIRamWorkspaceUnavailable` (warning) replaces `CIRamWorkspaceDegraded`: it fires only for claims routed to NVMe for 15 minutes as absent, seeding or unpublished. - `CIRamPoolUndersized` records a capacity finding in the Alerts ledger without email (new `category = "ci-capacity"` route) when the full share stays above 30% of at least 20 claims for 30 minutes. 30% is the top of the sizing model's 9% to 30% range (12% at the measured mix). - kube-state-metrics exports the new claim label; prometheus/prod/15 now carries the allowlist and the ledger route. Verification - bunx turbo run build typecheck test lint --filter=@homelab/cdk8s --filter=homelab --filter=@shepherdjerred/ops-model: pass. - promtool tests: the 6h counts and shares count each claim once; Unavailable fires after 15 minutes of seeding-routed claims and stays quiet for full and briefly unpublished routing; Undersized fires at 70% of 20 claims after 30 minutes and stays quiet at 20% and with only 15 claims. - Alert routing test: ci-capacity warnings go to alerts-ledger-only, CI warnings to alerts. - bun run generate:catalog: prometheus/prod/15 differs from /14 only in the kube-state-metrics allowlist (keeping deployments=) and the ledger route. - bun run check:kubeconform: 0 invalid; jscpd, quality-ratchet, knip: pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…te it on a compile check and canary Why The routing CEL is checked only as rendered text, and the NVMe clone guard that every CI workspace claim passes through had gained a new expression. A bad expression there would break golden clones for all of CI. What - Revert the NVMe clone guard's RAM-snapshot exclusion: the NVMe clone mutation and guard render byte-identical to main again. The routing policy never names a RAM snapshot for an NVMe claim, and the ZFS driver refuses a cross-pool clone anyway. - The routing mutation and its guard match only `ci-workspace-ram` claims (the mutation also only unsourced ones); a test pins the exact matchConditions. No agent creates such a claim before the RAM agents and flag land. - The production routing binding skips claims labelled `ci.sjer.red/workspace-route-canary`, so an operator's canary binding and ConfigMap can route a canary claim without touching the live route. - liskov README: a server-side dry-run compile check of every rendered admission policy before merge, and a canary that reads back the mutated claim for ready, absent and ready again before the flag routes work. Verification - bunx turbo run build typecheck test lint --filter=@homelab/cdk8s --filter=homelab: 33/33. - Rendered NVMe clone policy (mutation, guard, bindings) from main and from this branch: identical. - The dry-run file selection lists all 34 admission objects, including the route policy and guard. - Not run: the dry run and the canary themselves (operator, live API server). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ert when it stops publishing Why The whole ci-ram-pool pod mounted a service-account token, so the privileged pool container held API credentials it never uses. Nothing bounded the publisher's API calls, and an idle pool published an unchanged route, so a hung or dead publisher was indistinguishable from a quiet one while the routing policy kept applying its last route. PR 1's ashift 12 also moved the full-share model behind CIRamPoolUndersized. What - The pod sets automountServiceAccountToken: false; a projected token and the cluster CA are mounted only in ci-ram-pool-route, at the path kubectl's in-cluster configuration reads. - Every publisher kubectl call carries --request-timeout=10s. Each publish writes publishedAt (epoch seconds), so the route ConfigMap's resourceVersion changes every 15 seconds, and a heartbeat; a liveness probe restarts the publisher once its last successful publish is 60 seconds old. The routing CEL still requires only its six routing keys, so publishedAt is tolerated; a test pins that. - CIRamRouteStale (warning, 10m): changes() of kube_configmap_metadata_resource_version for woodpecker-ci/ci-workspace-route over 5m is 0. kube-state-metrics' configmap collector exports the series, so the prometheus/prod Helm configuration does not change. - CIRamPoolOverReservation moves to the ci-capacity ledger-only route this branch adds. - Full-share model rerun at ashift 12 (golden 6.06 GiB, unique data per verify 1.1 / 2.3 / 8.0 GB): about 15% of claims find the pool full, 12% to 36% across the sensitivity range, so CIRamPoolUndersized's threshold moves from 30% to 36%, the top of that range as before. - Wiki and liskov README: merging the flag's change is the rollout (its production override is on), so the server-side dry-run compile comes before the routing policy merges and the canary before the flag's change merges; the publisher's token, timeout, heartbeat and stale alert. Verification - bun run scripts/run-test.ts (packages/homelab/src/cdk8s) over src/resources/monitoring, src/resources/woodpecker, ci-ram-pool, cluster-baseline, kueue-config, src/misc, grafana/storage, backup-policy, helm-template and argo-applications/observability: 93 files, 621 tests pass, including promtool tests for CIRamRouteStale and the publisher tests for publishedAt, the heartbeat and the request timeout. - bunx turbo run build typecheck lint --filter=@homelab/cdk8s: pass. - bun run generate:catalog: no change to the prometheus/prod registration. - bunx lefthook run pre-commit: pass. - Not run: the server-side dry-run compile and the canary (operator, live API server); no live change was made. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
This change is part of the following stack: Change managed by git-spice. |
Contributor
|
Automatic reviews are disabled for this repository. Configure in Code Review Settings. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This was referenced Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The RAM pool from #5495 needs a storage class, and every RAM workspace claim needs one decision: clone the pool's own golden workspace (ZFS clones only within a pool), or run on NVMe because the pool is absent, unseeded or full. Two overlapping full-graph verifies can exceed the 24 GiB pool, so a claim must stop going to RAM before the pool fills.
PR 2 of 5. Nothing routes to these classes until the agents (PR 4a) and the
woodpecker-ram-workspace-enabledflag (PR 4b).Rollout order. Merging PR 4b is the rollout: its production override turns
woodpecker-ram-workspace-enabledon, so lanes route as soon as it syncs; there is no later switch-on step. So the gates come before merges: the server-side dry-run compile of the routing CEL (Verification below) must pass before this PR merges, and the canary in the liskov README must pass before PR 4b merges.What
ci-workspace-ram(workspaces) andci-golden-ram(the RAM golden claim): thin, zstd-1, Delete, liskov only. RAM workspaces are 12Gi, the per-clone quota.ci-ram-pool-routecontainer publishes ConfigMapci-workspace-routefrom that and both golden ConfigMaps:ready,full(under the 12Gi quota plus 2 GiB free),seeding(no golden for this pool generation, as after every reboot) orabsent(missing, not ONLINE, or stale). An API error stops the publisher instead of publishing a guess.automountServiceAccountToken: falseand a projected token (with the cluster CA) is mounted only inci-ram-pool-route, so the privileged pool container has none. Everykubectlcall carries--request-timeout=10s. Each publish writespublishedAt(epoch seconds), so the ConfigMap's resourceVersion changes every 15 s even on an idle pool, and records a heartbeat; a liveness probe restarts the publisher once its last successful publish is 60 s old.publishedAtis informational: the routing CEL requires only its six routing keys, and a test pins that.ci-workspace-ramclaim, so there is no reinvocation ordering with the NVMe clone policy.readyclones the RAM golden and labelsci.sjer.red/workspace-route=ram. Any other state, or a missing ConfigMap, makes it a 32Gici-workspaceclaim cloned from the NVMe golden, labellednvme-degraded. Every claim also carriesci.sjer.red/workspace-route-stateand, when degraded, a reason annotation. Guards reject a RAM claim that is not a labelled 12Gi RAM-golden clone, and an NVMe claim cloned from a RAM golden.fullis routine, so it is tracked, not paged:CIRamWorkspaceUnavailable(warning) fires when claims are routed to NVMe for 15 minutes asabsent,seedingorunpublished: an outage, or a reseed that is not finishing.ci_workspace:ram_route_claims:count6handci_workspace:ram_route_share:ratio6hrecord each state's share. A panel draws it beside the CI pool writer budgets.CIRamPoolUndersizedrecords a capacity finding in the Alerts ledger without email (a newcategory = "ci-capacity"route) when thefullshare stays above 36% of at least 20 claims for 30 minutes. PR 1'sCIRamPoolOverReservationmoves to the same ledger-only route.CIRamRouteStale(warning) fires whenkube_configmap_metadata_resource_versionforwoodpecker-ci/ci-workspace-routehas not changed in 5 minutes for 10 minutes: nothing is publishing, and the policy would keep applying the last route. kube-state-metrics already exports the series (configmaps are a default collector; the metric is listed in its configmap docs).deployments=entry kept) and the ledger route. ops-verify (FM-322) confirms nothing else claims /15. The rollout owner registers and rebinds it after merge (toolkit deploy catalog reconcile --machine, thentoolkit deploy rebind prometheus/prod --configuration prometheus/prod/15).Demo
No claim made today is evaluated by the new CEL.
has(object.spec.storageClassName) && object.spec.storageClassName == 'ci-workspace-ram'with no data source, and its guard matches only that class. A test pins both. No agent creates such a claim until PR 4a/4b.An earlier commit on this branch had added a RAM-snapshot exclusion to the NVMe guard. That would have put new CEL on every CI claim, so it was reverted. The routing policy never names a RAM snapshot for an NVMe claim, and the ZFS driver refuses cross-pool clones anyway.
Routing decisions from the real publisher script, run against a fake
kubectl(workspace-route.test.ts):readyci-workspace-ram12Gi, clone ofci-workspace-golden-ram-…,route=ramfullci-workspace32Gi, clone of the NVMe golden,route=nvme-degradedreadyseedingMISSINGorSUSPENDEDabsentExpected
full-routed share, the basis for the 36% threshold (Monte Carlo,.spike/full_share_sim_a12.ts, rerun for PR 1's ashift 12):tiers.tsp50 and p90.fullshareThe simulated pool peaks at 21.9 GiB and never reaches the 24 GiB cap at today's two-verify concurrency. A sustained
fullshare above 36% means the mix is heavier than the pessimistic case: the pool is undersized.Alert tests (promtool):
seeding-routed claims. It stays quiet for a pool that isfullall day.publishedAton an idle pool.Verification
Invalid valueor compilation error:status.typeCheckingonwoodpecker-workspace-route.sjer.redandwoodpecker-workspace-route-guard.sjer.redmust be empty.ci.sjer.red/workspace-route-canary).bunx turbo run build typecheck test lint --filter=@homelab/cdk8s --filter=homelab --filter=@shepherdjerred/ops-model: pass.bun run generate:catalog: prometheus/prod/16 as above.bun run check:kubeconform(packages/homelab): 1531 resources, 0 invalid.bunx turbo run jscpd quality-ratchet knip --filter=//: jscpd and quality-ratchet pass;knipfails only on an unused@base-ui/reactinpackages/mail/package.jsonfrom main's feat(mail): shared console shell, banner, description list and email preview #5483, which this stack does not touch.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.🤖 Generated with Claude Code