Repository navigation
feat(buildkitdrive): a 100 GB GC budget by default, and every daemon setting configurable - #653
Conversation
…setting configurable buildkitd's compiled GC policy keeps a 373 GB free-space target and a 10 GB reserve floor; on a host with less free space the GC prunes reclaimable cache to that floor on every pass, so a repeated build of an unchanged tree re-executes its layers (opencharly/charly#1292). DaemonOptions now renders the full [worker.oci] surface (process-mode, max-parallelism, snapshotter, noProcessSandbox, the three-space GC budget, per-record gcpolicy entries, the registry mirror and a raw extra block), DaemonConfig defaults the budget to reservedSpace=100GB / maxUsedSpace=100GB / minFreeSpace=10GB, and Ensure writes the rendered config whenever it differs and reports a RUNNING daemon's GC mismatch on stderr (the policy is fixed at daemon start). This is the clean PR for the auto-closed #650 thread: the surviving finding there was a real defect in this change's own test — the legacy-key guard matched camel-case 'keepStorage' while buildkitd's legacy key is all-lowercase 'gckeepstorage', so it could never fire. The guard is now case-insensitive and names the real key, with the red arm pasted in the PR body. *Agent: `jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5` · OpenCode session `ses_de3fa473bffeFiBo62whHxDPE5`* *Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)*
Review — BLOCKHead SHA: Change class: code/config — sdk library kit ( Blocks
Note (non-blocking)
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
… and the report says so ConfigGC treated a missing gc key as disabled, so the mismatch report told the operator a pre-budget daemon was 'started with gc disabled' — the exact opposite of the truth: buildkitd's worker GC runs by default with keepstorage 10000,373000,100000 (10GB reserve, 373GB free target, 100GB ceiling), which is the policy that prunes a small host's cache to the floor. GCConfig now carries Explicit: absent means the daemon's default (enabled) and Describe() names that policy; an explicit gc=false still describes as disabled; an explicit budget describes its three spaces. wantedGC() marks the requested state explicit so the report renders the requested values. Red arm: restoring absent=disabled fails both report tests. *Agent: `jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5` · OpenCode session `ses_de3fa473bffeFiBo62whHxDPE5`* *Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)*
|
STATUS New head What was wrong. Fix.
Both report tests assert the corrected wording, plus a new arm: absent ⇒ enabled+not-explicit and describes as the default; explicit Non-blocking note — fixed too. The R2 line no longer claims a deletion: this clean tree never carried Gate on the head: RCA for the missed control. Mechanism: I took the daemon's TOML field default ( Agent: |
Review — PASSHead SHA: Security screen: PASS — no secrets, no egress, no guardrail weakening; Comment dispositions:
Non-blocking notes:
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
charly box buildof an unchanged tree re-executes its layers on this host. The cause is not the per-build tag (a changed tag with an unchanged digest is a cache HIT): it is BuildKit's own GC pruning the cache. buildkitd's compiled default policy keeps a 373 GB free-space target (--oci-worker-gc-keepstorage 10000,373000,100000MB); this host has 247 GB free, so every GC pass prunes reclaimable cache toward the ~10 GB reserve floor. The next build then re-executes the evicted layers, and the floatingpacman -Syu/releases/lateststeps change the bytes, so the image digest (and the CalVer tag minted for it) moves.Measured 2026-11-27 (buildkitd 0.35.1, 1.9 TB disk at 87% used):
The change.
DaemonOptionsnow carries the whole[worker.oci]daemon surface charly manages —process_mode,max_parallelism,snapshotter,no_process_sandbox, the GC budget (reservedSpace/maxUsedSpace/minFreeSpace), per-record[[worker.oci.gcpolicy]]entries, the registry mirror, and a rawextraTOML escape hatch — andDaemonConfigalways writes an explicit 100 GB GC budget (reservedSpace = "100GB",maxUsedSpace = "100GB",minFreeSpace = "10GB").Ensurereports, without failing the build, a running daemon whose GC policy predates the request; the value takes effect at the next daemon start.This is the producer leg of the
charly.ymlsurface (defaults.buildkit) implemented inopencharly/specand consumed byopencharly/plugin-build.How tested
This is the clean PR for the auto-closed #650 thread. The surviving finding there was a real defect in this change's own test: the legacy-key guard matched camel-case
keepStorage, but buildkitd's legacy worker key is all-lowercasegckeepstorage, so the check could never fire. It is fixed here (case-insensitive, names the real key) and the red arm is pasted.Contract-module change class (no deployable target in
sdk): the repo's own module CI is the gate, run on this head.The new tests pin: the 100 GB default is rendered; every optional worker/GCPolicy knob (
process_mode,max_parallelism,snapshotter,no_process_sandbox,gc, the three-space budget,gcpolicyincl.all/keep_duration/filters,registry_mirror, the rawextrablock) renders when set AND is omitted at its zero value (TestDaemonConfig_RendersEveryWorkerKnob, which fails if any branch is dropped — verified by deleting thesnapshotterbranch:the rendered config must carry "snapshotter = \"overlayfs\""); a disabled GC renders no budget; the rendered policy reads back throughConfigGCfor the running-daemon comparison; the legacy worker keygckeepstorage(all lowercase, mirroring--oci-worker-gc-keepstorage) and the 373 GB default value are not emitted — the guard is CASE-INSENSITIVE, and its red arm is pasted below; and BOTH newEnsurebranches are exercised onEnsureitself (not only through the pure helpers):TestEnsureRewritesAStaleConfigWithoutParallelismstarts from the pre-GCmax-parallelism = 4file and assertsEnsureREPLACES it with the rendered config for an options value carrying no parallelism (the start seam captures the spawn and materialises the socket). It FAILS on the unmodified tree, where that branch skipped the write:TestEnsureReportsTheRunningDaemonsGCPolicypre-creates the socket (soreadytakes the listening branch), starts from a pre-GC config whose parallelism matches (so no restart is demanded), swaps the process stderr for a pipe, and asserts the report names the configured policy and the socket. It FAILS without the report:Red arm for the GC-default accuracy fix — the parser restored to "absent = disabled":
Red arm for the legacy key — the renderer made to emit the legacy key:
Spike
RCA claim: the cache loss is BuildKit's GC pruning (default free-space target 373 GB > this host's 247 GB free), not the per-build tag.
Candidates spiked:
buildkitd --helpdefault +buildctl du+ a captured per-step build. Result: fails — the cache floors at ~10 GB and the builder's large RUNs re-execute while a small one stays cached.TestDaemonConfig_CarriesTheGCBudget) +ConfigGCround-trip. Result: works (rendered and read back); the live daemon-level effect is the consumer boundary's bed (the charly pin-bump PR), per the contract-module gate.minFreeSpacesmall, leave the rest to the default. Rejected by inspection, with the daemon's own defaults as the instrument:Winner: B. RCA verdict: confirmed — the default policy's free target is the pruning driver; the explicit budget removes it.
Rulebook compliance
build/generate/go/strict-policy/check/git-workflowloaded before the work.gc= enabled withkeepstorage 10000,373000,100000), not "disabled"; the two report tests assert that wording and fail if the parser reverts. The anomaly was reproduced and measured before the change; the label-position hypothesis was tested and disproved (aLABELvalue change, top vs end, leaves theCOPY/RUNlayers CACHED on 0.35.1 — labels are already emitted at the end of every generated Containerfile). The floating-input non-reproducibility is tracked separately on the base builder is rebuilt under a new CalVer tag on every build, so no layer is ever reused charly#1292.DaemonConfig) and one write comparison (writeIfChanged); the GC comparison reuses the same rendered form. (This clean tree never carried the intermediateConfigDiffershelper from the superseded thread, so there is nothing deleted here.)sdkships nodisposable: trueentity, so no bed can exist. Every changeddaemon.gopath is reached by a test that fails without it:TestGCConfigMismatch(the pure report),TestEnsureReportsTheRunningDaemonsGCPolicy(the daemon-LISTENING branch, i.e. thefmt.Fprintfwiring) andTestEnsureRewritesAStaleConfigWithoutParallelism(the no-daemon always-write branch). The consumer boundary bed rides thecharlypin-bump PR.spec/storeroot(D-STORE-1).Change classification
The default GC budget changes behaviour: a buildkitd started by this drive keeps up to 100 GB of cache instead of pruning to ~10 GB, and an already-running daemon keeps its old policy until restarted (reported on stderr, never fatal). Breaking change + rollback: none for the module API beyond new optional fields on
DaemonOptions; rollback is a revert of this squash, which restores the GC-unset renderer.Filed issues
pacman -Syu/releases/latestinputs change the bytes on a cold rebuild (the non-reproducibility that makes the digest, and therefore a minted tag, move).Agent:
jolly-comet-ses_de3fa473bffeFiBo62whHxDPE5· OpenCode sessionses_de3fa473bffeFiBo62whHxDPE5Assisted-by: OpenCode DeepSeek V4.1 Flash (fully tested and validated)