Repository navigation
post: fstrim the buildkit sticky disk before unmount at commit - #143
Open
magma-beef wants to merge 2 commits into
Open
magma-beef wants to merge 2 commits into
magma-beef wants to merge 2 commits into
Conversation
Pruned layers keep their RBD extents allocated on the backing store until the guest discards them. Run a best-effort fstrim on /var/lib/buildkit before unmount, only when the run is still on track to commit (integrity check passed, no early deny, no SIGKILL, no failed steps) and only when the host enabled it: the VM agent returns GetStickyDiskResponse.fstrim_timeout_secs (fa live config guest_fstrim_timeout_secs), saved in action state at mount time; 0 means no trim. Any failure or timeout only logs. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ackage predates it The bundled GetStickyDiskResponse has no fstrim_timeout_secs yet, and protobuf-es keeps fields it does not know in $unknown (the gRPC transport is binary), so decode field 8 from there when the typed field is absent. Releases built before the field existed therefore honour the host budget once the agent sends it. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
This was referenced Oct 20, 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.
Summary
Feature — the post step runs a best-effort
fstrimon the buildkit sticky disk (/var/lib/buildkit) right before unmounting a disk it is about to commit, for at most the number of seconds the VM agent sends. Nothing changes until a host is configured: the agent sends 0 today, and the hypervisor does not negotiate discard yet.Start here:
src/setup_builder.ts(trim helper + where it sits in cleanup), thensrc/main.ts(reads the budget from the mount response, saves it in state).dist/is generated.Why
The buildkit sticky disk is the largest sticky-disk population by bytes. It is an RBD image; layers buildkit prunes stay allocated in Ceph until the guest discards them (fleet-wide ~47 % of allocated sticky-disk bytes are filesystem-free, measured 2026-10-19). Same change as useblacksmith/stickydisk#82 for the bare action.
What
commitEarlyDeny, no SIGKILL, no failed steps) and the host enabled the trim, runtimeout <secs> sudo fstrim -v -- <mount>after buildkitd stops and before the df sample andumount. Any exit code or exception only logs (fstrim <mount>: <output> in Nms | failed in Nms: timed out after Ns | ...). The previous-step check is evaluated once and reused for the commit decision, so skip reasons are unchanged.GetStickyDiskResponse.fstrim_timeout_secs(FastActions/fa#6600, live configguest_fstrim_timeout_secs), saved in action state at setup. 0/absent = no trim, so this release does nothing until the agent sends a budget — the rollout and its tuning are agent-side.fstrimTimeoutSecsFrom()reads the typed field when the bundled proto package has it, else unknown field 8 from$unknown(protobuf-es keeps unknown binary fields; the transport is gRPC), so this version keeps working once the agent starts sending the field without a package bump.Evidence
pnpm testfstrimTimeoutSecsFrom(typed field, unknown field 8 on a real response decoded with the field-less schema, wrong wire type),decodeVarint,parseFstrimTimeoutSecsRisks
Verdict: Ship. With the agent sending 0 (current default) post only reads one state value; the trim path is reachable only after a host is configured.
Worry about: once a host is configured and discard is negotiated, the first trim of a large never-trimmed buildkit disk runs until the budget expires and post is longer by up to that budget; later trims are incremental.
Checked, not worried: every trim failure mode (unsupported discard, missing binary, timeout) logs and continues; the trim runs after buildkitd is stopped and before the df sample, so the committed state and the sample agree; non-commit runs skip it.
If it goes wrong: post logs
fstrim /var/lib/buildkit: failed ...; setguest_fstrim_timeout_secsback to 0 on the host — no action release needed.Related: useblacksmith/stickydisk#82, useblacksmith/checkout#63, FastActions/fa#6600, useblacksmith/web#18629.
Link to Devin session: https://app.devin.ai/sessions/2e17815c306b4c3cb7af4f6bce008a66
Open in Devin Desktop: https://app.devin.ai/desktop/session/2e17815c306b4c3cb7af4f6bce008a66?variant=devin
Requested by: @magma-beef
Need help on this PR? Tag
@codesmith-botwith what you need. (Staging)Need help on this PR? Tag
@codesmith-botwith what you need.