Skip to content

post: run the fstrim timeout under sudo so it can stop fstrim - #149

Open
magma-beef wants to merge 1 commit into
mainfrom
devin/1793913469-fstrim-sudo-timeout-v1
Open

magma-beef wants to merge 1 commit into
mainfrom
devin/1793913469-fstrim-sudo-timeout-v1

Conversation

@magma-beef

@magma-beef magma-beef commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Bug fix to the pre-unmount trim from #147 (v1 line; #148 is the same fix on release/v2). trimFilesystem ran timeout <secs> sudo fstrim ...: the unprivileged timeout cannot signal the root-owned sudo/fstrim it spawned (EPERM), so the host budget never bounded the trim and a slow fstrim could outlive it and keep the buildkit mount busy at unmount.

- timeout ${timeoutSecs} sudo fstrim -v${minimum} -- "${mountPath}"
+ sudo timeout ${timeoutSecs} fstrim -v${minimum} -- "${mountPath}"

sudo passes timeout's exit 124 through, so the timeout classification in setup_builder.ts is unchanged. Verified on a runner image: timeout 2 sudo sleep 30 leaves sudo sleep 30 running; sudo timeout 1 sleep 30 exits 124 with the child gone.

Start here: src/main.ts (trimFilesystem). dist/ is the regenerated bundle.

No behavior change in prod today: hosts send budget 0, so the trim is skipped before this command runs.

Checks: lefthook pre-commit (prettier, eslint, tsc, build, dist diff).

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


Show it working
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


🟢 Devin Review found nothing to fix · View findings

Devin Review


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

An unprivileged timeout cannot signal the root-owned sudo/fstrim it
spawned, so the host budget never bounded the trim and fstrim could
outlive it and keep the buildkit mount busy. sudo timeout <secs> fstrim
gives timeout the privilege to kill fstrim; exit 124 still maps to the
timeout outcome.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@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

@blacksmith-staging

blacksmith-staging Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Matches Slow fstrim stops at the budget

After, the trim returns as a timeout at the 3s budget with nothing left running for both stand-ins. Before, a single-process fstrim was already stopped at 3s here; only when the work ran in a child process did it outlive the budget and hold the trim for 20s.

Merge-base

Before: slow fstrim

This PR b65d93d8

After: slow fstrim

Also checked · 1 match

Matches Real fstrim outcomes unchanged

Proof on b65d93d8 · mocked: fstrim (a genuinely slow trim needs a large RBD-backed sticky disk; a root-owned stub th...) · not run: Blacksmith host agent / sticky disk API (not needed) · Did Proof get it right? Yes · No

View full Proof report

@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

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