Repository navigation
fix(ci): bound source cache snapshots so PR bursts cannot fill main's claim - #5542
shepherdjerred wants to merge 3 commits into
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
|
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
|
|
@codex review Automated re-review request for |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d09284a10
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
edcb2d2 to
0c8796a
Compare
… claim Why Main pipeline #20941 (and #20949) failed in prepare-clone with "chown: /woodpecker/source-cache: Disk quota exceeded". Every source-cache miss publishes a complete depth-one object store (1,247,308,780 bytes), and ZFS charges each block clone to the 20 GiB claim in full. Collection runs every five minutes and keeps 8 GiB (six snapshots), so nothing bounded what a burst adds between two runs. Since #5378, owner pull requests publish into woodpecker-source-main; before it, main never wrote more than 4 snapshots in a window. Between 03:35 and 03:40 UTC on 2026-12-03, 19 distinct owner-PR and main commits started, 12 snapshots landed on top of the six retained (18 x 1.165 GiB = 20.97 GiB on disk), and every checkout on the claim, hits included, failed until the 03:40 collection removed 12. What - src/checkout/admission.ts: a miss reserves its snapshot's size in the claim (a reservation file published by rename) before fetching, and publishes only while all published and in-flight snapshots stay under a ceiling of the claim's statfs capacity: 70% for proposals, 85% for main pushes and manual runs. Writers announce before they count, so concurrent writers can both be refused but never both overshoot. Reservations are restated with the real size after the fetch and checked again. - snapshot.ts: a refused miss still checks out from its own fetch, reports published=false in CI_CHECKOUT_DIAGNOSTIC, never touches the cache, and removes its reservation on any failure. - checkout.sh hands the helper the locked commit descriptor; on refusal the helper unlocks it with flock, so the commit's other workflows fetch in parallel instead of queueing behind an unpublished fetch. - cacheSourceSteps emits CI_SOURCE_CACHE_TIER: main only for trusted default-branch work. Claims are unchanged: owner PRs keep sharing woodpecker-source-main, and Renovate, App, fork and credentialless builds keep woodpecker-source-pr or no cache, exactly as #5378 decided. - README and the CI pipeline explanation describe the ceiling. Verification - bunx turbo run build typecheck test lint --filter=@shepherdjerred/woodpecker-config-extension: 9/9 tasks, 492 tests. - New test/checkout/source-cache-admission.test.ts: ceilings on a 20 GiB claim, 20 concurrent reservations never overshoot, sequential misses stop at exactly six above the retained six, main admitted where proposals are refused, undeclared in-flight copies count in full, a refused miss checks out, unlocks once before fetching and leaves no snapshot, an empty cache is bounded after its fetch, hits need no room. - Linux probe in oven/bun:1.4.5 (the extension's base image): a waiter on the commit lock acquires it after 0 ms when the helper unlocks fd 9 via flock, versus 2503 ms when it holds it. - Replaying the incident's 19 commits through the module keeps the claim at 15.10 GiB (ceiling 17 GiB, quota 20 GiB); main's ce8aa95 still publishes. - bunx turbo run jscpd quality-ratchet knip --filter=//: pass. - bunx lefthook run pre-commit: pass. - Not verified: exact-head CI, the deployed extension, and a live burst on woodpecker-source-main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Why Review of the source-cache ceiling found that a writer killed mid-copy (Woodpecker cancels superseded workflows with SIGKILL) leaves its reservation behind. The admission survey counts it at a full snapshot, while the collector sums real bytes and kept it for up to seven days, so about three cancels would eat main's band and about twelve would block proposal publication. Two smaller gaps: a published snapshot missing its manifest failed every miss on the claim, and a pipeline emitted without a tier would crash the helper. What - source-cache-gc.ts: the collector holds the GC lock exclusively, which every checkout holds shared for its whole run, so it now removes every in-progress copy and any snapshot without a manifest on each five-minute run, whatever their age, and reports them as abandoned. - admission.ts: a published snapshot without a manifest counts at full size with a warning instead of failing the survey; the collector removes it. - commit-lock.ts: the flock-based release of checkout.sh's descriptor 9, moved out of main.ts so it can be tested. - main.ts: a missing CI_SOURCE_CACHE_TIER publishes under the proposal ceiling for rollout compatibility; a wrong value still fails. - Tests: separate-process writers never overshoot together; a SIGKILLed writer's reservation persists and counts; the collector removes it; a restated reservation above the room left withdraws only itself; surveys hold while writers withdraw; lock release happens before the fetch on a pre-fetch refusal and after it on a post-fetch refusal; on Linux, the real flock release frees descriptor 9 while the helper keeps running. Verification - bunx turbo run build typecheck test lint for the extension and @homelab/cdk8s: 40/40 tasks; extension 497 passed, 1 skipped (the Linux-only flock test on macOS); cdk8s 3194 passed. - The Linux-only test's protocol, run in oven/bun:1.4.5 with the real fixture: waiter exit 1 while held, 0 after the release. - Live, read-only: statfs on woodpecker-source-main reports 163840 blocks of 131072 bytes = 21474836480 bytes, the PVC's 20Gi and the ZFSVolume's capacity with quotaType "quota". - bunx turbo run jscpd quality-ratchet knip --filter=//: pass. - bunx lefthook run pre-commit: pass. - Not verified: exact-head CI, deployment, and a live burst. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Why Restacking onto #5556 brought a new emit test that calls cacheSourceSteps without the `main` input this branch made required, so typecheck failed. What - The test now passes `main: true` for its trusted cached steps. #5556's assertDeclaredCheckout and this branch's tier and commit-lock setup are both kept in checkout/main.ts after resolving the restack conflict. Verification - bunx turbo run build typecheck test lint for the extension and @homelab/cdk8s: 40/40 tasks; extension 504 passed, 1 skipped (the Linux-only flock test on macOS); cdk8s 3194 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0c8796a to
2c65ffe
Compare
Why
Main went red at ce8aa95 (#20941 and #20949):
prepare-cloneinhelm-push,scout-site-archivesandtrmnl-plugin-archivesfailed withThe cache is keyed per commit, and every miss publishes a complete depth-one object store: 1,247,308,780 bytes, or 1.165 GiB on disk. ZFS charges each block clone to the 20 GiB claim in full. The Temporal collector runs every five minutes and keeps 8 GiB, which is six snapshots. Nothing bounded what a burst could add between two runs. Since #5378, owner pull requests publish into
woodpecker-source-main. Between 03:35 and 03:40 UTC, 19 distinct owner-PR and main commits started. Twelve snapshots landed on top of the six retained, 18 × 1.165 GiB = 20.97 GiB, and from then on every checkout on the claim failed, hits included, until the 03:40 collection removed 12. Thechownis not recursive. It fails because ZFS refuses any write to a dataset that is over its quota.The Woodpecker 3.21 upgrade (FM-411) is not a factor: the server and all six agents still run v3.20.1.
What
src/checkout/admission.ts(new). Before fetching, a miss reserves its snapshot's size in the claim. The reservation is a file published by rename. The snapshot is published only while all published and in-flight snapshots stay under a ceiling of the claim'sstatfscapacity: 70% for proposals and 85% for main pushes and manual runs. Writers announce before they count, so two concurrent writers may both be refused but can never both overshoot. After the fetch, the reservation is restated with the real size and checked again.snapshot.ts. A refused miss still checks out from its own fetch. It reportspublished: falseinCI_CHECKOUT_DIAGNOSTICand never touches the cache. A failure at any point removes the reservation.checkout.shandmain.ts. The script hands the helper the locked per-commit descriptor (fd 9). On refusal, the helper unlocks it withflock. The commit's other workflows then fetch in parallel instead of queueing behind a fetch that will never publish.cacheSourceSteps. It emitsCI_SOURCE_CACHE_TIER, which ismainonly for trusted default-branch work. Claims are unchanged. Owner PRs keep sharingwoodpecker-source-main. Renovate, App, fork and credentialless builds keepwoodpecker-source-pror no cache, exactly as feat(ci): share main's build cache with owner pull requests #5378 decided. The proposal ceiling sits below main's, so a PR burst cannot take main's last headroom.homelab/.../source-cache-gc.ts) holds the GC lock exclusively, and every checkout holds it shared for its whole run, so no writer is ever live while it runs. On each five-minute run it now removes every in-progress copy and any published snapshot missing its manifest, whatever their age, and logs them asabandoned. A dead reservation therefore holds room for at most one collection interval instead of up to seven days.CI_SOURCE_CACHE_TIERpublishes under the proposal ceiling, for rollout compatibility. A wrong value still fails. In practice the emitter and helper ship in one image (CI_GATE_IMAGEis the extension's own recipe).commit-lock.ts. Theflockrelease moved out ofmain.tsso it can be tested.I chose not to resize the claim. A bigger quota only moves the cliff: absorbing this one window (6 + 19 snapshots) would take about 30 GiB, and a longer backlog needs more. I also chose not to route owner PRs back to
-pr. That would reverse #5378's choice to keep owner PRs off Renovate-written volumes, and the same burst would then break owner PRs on-pr, where the peak before #5378 was already 11 snapshots per window.Demo
Live evidence from the source-cache collector, which runs every five minutes. Each run evicts back to six snapshots, so evicted + 6 is the peak since the previous run.
The
prepare-clonefailures were at 03:39:49 UTC.woodpecker-source-prhas had no writes since 2026-11-30, because #5378 took owner PRs off it.#5378 moved the dominant writer onto main's claim. Snapshots published per five-minute window, from 7 days of collector logs in Loki:
woodpecker-source-mainwoodpecker-source-mainwoodpecker-source-prThe incident's 19 commits replayed through the real admission module. The replay starts from the six retained snapshots on a 20 GiB claim, in the order the commits started.
The claim peaks at 15.10 GiB, under the 17 GiB main ceiling and the 20 GiB quota, and main's own push still publishes. Rows 2 to 5, 8 to 11, 13 and 16 to 18 behave like their neighbors.
statfsreports the ZFS quota (review P2), checked read-only on the live claim.stat -f /woodpecker/source-main(in pod)df -B1sizewoodpecker-source-main20Gi= 21,474,836,480pvc-26793d60…(OpenEBS)capacity: "21474836480",quotaType: "quota", no snapshots (backup off)zfs getis not reachable without host access. The provisioner sets exactly this quota, so the ceiling's base is the quota itself.Releasing the commit lock works on Linux in the extension's base image (
oven/bun:1.4.5). A second workflow waits on fd 9 while the helper runs:Bun gives a child only the descriptors its
stdioarray names, so the helper passes fd 9 toflock --unlock 9at index 9.Verification
bunx turbo run build typecheck test lint --filter=@shepherdjerred/woodpecker-config-extension --filter=@homelab/cdk8s: 40/40 tasks. The extension has 497 passed and 1 skipped (the Linux-onlyflocktest, on macOS); cdk8s has 3194 passed.test/checkout/source-cache-admission.test.tscovers:test/checkout/source-cache-writers.test.tscovers:flock --unlockpath freescheckout.sh's descriptor 9 while the helper keeps running. The same protocol was run inoven/bun:1.4.5against the real fixture: waiter exit 1 while held, 0 after the release.source-cache-gc.test.ts: the collector removes a killed writer's copy and a manifest-less snapshot even when both are fresh and under target, and keeps the rest.test/source-cache.test.tspins the claim and tier per build shape: main push →main/main; owner PR →mainclaim withproposaltier; Renovate →pr/proposal.bunx turbo run jscpd quality-ratchet knip --filter=//: pass.bunx lefthook run pre-commit: pass.bun run verify:extended -- --filter='...[origin/main...HEAD]': exit 0, 33/33 tasks, run in@homelab/cdk8s,@shepherdjerred/docs-wikiand@shepherdjerred/woodpecker-config-extension.woodpecker-source-main.🤖 Generated with Claude Code