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, saved in action state at mount
time; 0 means no trim. A positive fstrim_min_extent_bytes becomes
`fstrim -m`. Any failure or timeout only logs.
Port of #143 (release/v2) to the v1 line; v1 has no DockerJobLifecycle
report, so the trim result is logged only.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary
Port of #143 (release/v2) to the v1 line: the post step runs
fstrimon the buildkit sticky disk before unmounting and committing it, so freed blocks are discarded from the backing image.GetStickyDiskResponse.fstrim_timeout_secsand the minimum free extent infstrim_min_extent_bytes(bumped@buf/blacksmith_vm-agent.bufbuild_es); setup stores both in action state. A0/absent budget disables the trim; a0/absent minimum keeps fstrim's default.sync, before the usage sample andumount.timeout <budget> sudo fstrim -v [-m <bytes>]: a missing binary, unsupported discard, or timeout is logged and never fails the step. v1 has noDockerJobLifecyclereport, so the result is log-only.Prod impact: none at merge. The trim runs only when the agent sends a positive
fstrim_timeout_secs, and v1 users pick it up with the next v1 release/tag.Start here:
src/main.ts(post step,trimFilesystem), thensrc/setup_builder.ts(parseFstrimTimeoutSecs,parseFstrimMinExtentBytes,fstrimFailureOutcome) andsrc/state-helper.ts.dist/is regenerated.Checks:
pnpm lint,pnpm typecheck,pnpm test,pnpm build.Link to Devin session: https://app.devin.ai/sessions/2b54a64701834e1ca263ab9a9e881691
Open in Devin Desktop: https://app.devin.ai/desktop/session/2b54a64701834e1ca263ab9a9e881691?variant=devin
Requested by: @magma-beef
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need. (Staging)🟢 Devin Review found nothing to fix · View findings · Follow Devin's work