Skip to content

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

Open
magma-beef wants to merge 1 commit into
release/v2from
devin/1793913201-fstrim-sudo-timeout
Open

magma-beef wants to merge 1 commit into
release/v2from
devin/1793913201-fstrim-sudo-timeout

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 #143. 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 outcome 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: every host still sends budget 0, so the trim is skipped before this command runs.

Checks: pnpm lint, tsc --noEmit, pnpm test (64), pnpm 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


Prove it works
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

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 Budget now stops a slow fstrim

On Ubuntu 22.04 sudo, the before command let a slow real fstrim run its full course past a 3s budget; the after command stopped it at 3s, still classified timeout, with no fstrim left and a clean unmount. On Ubuntu 24.04 sudo the before command already stopped at 3s.

Merge-base

Before: trim ignores budget

This PR 8a0a92ce

After: trim stops at budget

Also checked · 2 match

Matches Trim within budget still reports bytes
Matches Unsupported discard still classified

Proof on 8a0a92ce · mocked: Sticky disk mount (/var/lib/buildkit) (unavailable), Post step trimFilesystem (dist/index.js) (unavailable) · Did Proof get it right? Yes · No

View full Proof report

@cursor

cursor Bot commented Nov 5, 2026

Copy link
Copy Markdown

This PR is too large for Bugbot to review. It changes 9 lines and 2,679,536 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 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