Repository navigation
post: fstrim the sticky disk before unmount at commit - #82
magma-beef wants to merge 7 commits into
Conversation
Sticky disks are RBD images; blocks a job frees are only reclaimed by the backing store once the guest discards them, so without a trim deleted files keep their 4 MiB RBD objects allocated and the disk's real usage ratchets up to its high-water mark. Run a best-effort `timeout 60 sudo fstrim -v` on the mount right before unmount, only when the commit will actually be requested, mirroring the docker-cache disk's trim in job_completed.sh. The trim never fails the post step and is a no-op until the hypervisor negotiates discard for the device. The commit decision (commit mode, early denial, on-change verdict, prior step failures) is now evaluated before unmount so the trim can be skipped for disks whose snapshot will be discarded. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
|
Waiting 60s is too long. How short can it be while staying useful. 5s? Also... since this code gets rolled out by customers, I feel like we should make it so we can inject this delay from the fa agent side, so we can do a slow rollout, and tune this in the future. |
|
Agreed on both. Plan:
The action can't compile against the new field until the proto lands on buf.build, so I'll link the fa PR here and update this one once it merges. |
The VM agent now returns GetStickyDiskResponse.fstrim_timeout_secs (fa live config guest_fstrim_timeout_secs). The main step saves it in action state and the post step trims only when it is positive, bounded by that many seconds, so the trim is off until a host enables it and its budget can be tuned without a new action release. Read through a cast so the action keeps compiling against the current generated proto package. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ckage predates it The bundled GetStickyDiskResponse has no fstrim_timeout_secs yet, and protobuf-es keeps fields it does not know in the message's unknown-field list (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, which is what makes an agent-side rollout possible. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Re @piob-io's comment (#82 (comment)) — implemented as of c4a2f7b:
Same shape for the docker (useblacksmith/setup-docker-builder) and git-mirror (useblacksmith/checkout) actions, branches pending PRs; the web schema PR adds the key to |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Bump @buf/blacksmith_vm-agent.bufbuild_es to a build that includes GetStickyDiskResponse.fstrim_timeout_secs (fa #6600) and drop the unknown-field-8 decoding. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
GetStickyDiskResponse.fstrim_min_extent_bytes (fa #6823) is saved as action state alongside the timeout budget and, when positive, becomes `fstrim -m <bytes>` so free extents smaller than the host's threshold are not discarded. Zero or absent leaves fstrim at its default. Bumps the @buf vm-agent packages to the fa main build that carries field 9. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>


In the post step, run
fstrimon the sticky disk before it is unmounted and committed, so freed blocks are discarded from the backing image.GetStickyDiskResponse.fstrim_timeout_secs(field 8).mainreads it (from the typed field, or from unknown field 8 when the bundled proto package predates it) and stores it in action state;0/absent disables the trim.postevaluates the full commit decision (mode, early deny, if-missing, on-change verdict, previous-step failures) before unmount and trims only when the budget is positive and a commit will be requested. Order: sync → df sample → trim → drop_caches → umount → flushbufs.timeout <budget> sudo fstrim -v; a missing binary, unsupported discard, or timeout only logs and never fails the step.Start here:
src/post.ts(commit decision, trim ordering), thensrc/mount.ts(trimFilesystem,fstrimTimeoutSecsFrom).dist/is regenerated.Checks:
npm run lint,npx tsc --noEmit -p .,npm test,npm run build.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.