Skip to content

post: fstrim the buildkit sticky disk before unmount at commit - #143

Open
magma-beef wants to merge 2 commits into
release/v2from
devin/1792451281-buildkit-fstrim
Open

magma-beef wants to merge 2 commits into
release/v2from
devin/1792451281-buildkit-fstrim

Conversation

@magma-beef

@magma-beef magma-beef commented Oct 20, 2026 •

Copy link
Copy Markdown

In the post step, run fstrim on the buildkit sticky disk before it is unmounted and committed, so freed blocks are discarded from the backing image.

  • The agent sends a trim budget in GetStickyDiskResponse.fstrim_timeout_secs (field 8). Setup reads 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.
  • Post trims only when the budget is positive and the run is still on track to commit (expose id present, no early deny, no SIGKILL, no failed previous steps). The trim runs after buildkitd shutdown and sync, before the usage sample and umount.
  • Best-effort: timeout <budget> sudo fstrim -v; a missing binary, unsupported discard, or timeout only logs and never fails the step.

Start here: src/main.ts (post step), then src/setup_builder.ts (fstrimTimeoutSecsFrom, trimFilesystem). dist/ is regenerated.

Checks: npm run lint, npx tsc --noEmit -p ., npx vitest run, npm run build.


View with [code]smith View full Proof
Need help on this PR? Tag @codesmith-bot with what you need. (Staging)


View with [code]smith Generate Proof with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@blacksmith-staging

blacksmith-staging Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Matches Post step trims freed blocks before unmount

After the change the post step runs fstrim before unmount and the backing image drops from 578M to 66M; before, it stays at 578M.

Merge-base

Post step, no trim

This PR 1b5022b1

Post step trims disk

Also checked · 3 match

Matches Budget read from field 8 over gRPC
Matches No trim when previous steps failed
Matches Trim failure never fails the step

Proof on 1b5022b1

View full Proof report

magma-beef and others added 2 commits October 22, 2026 21:25
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>
(cherry picked from commit 3d2979f)
…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>
(cherry picked from commit 56214f0)
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1792451281-buildkit-fstrim branch from 56214f0 to 1b5022b Compare October 22, 2026 21:27
@devin-ai-integration
devin-ai-integration Bot changed the base branch from main to release/v2 October 22, 2026 21:27
@cursor

cursor Bot commented Oct 22, 2026

Copy link
Copy Markdown

This PR is too large for Bugbot to review. It changes 9 lines and 1,709,694 characters. Split the change into smaller pull requests to get a review.

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin addressed Devin Review findings on 1b5022b

No findings needed changes.

View all findings in Devin Review

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant