dist: use bubblewrap for overlayFS mounts, run sccache-dist without root - #2728
dist: use bubblewrap for overlayFS mounts, run sccache-dist without root#2728rrbutani wants to merge 2 commits into
sccache-dist without root#2728Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2728 +/- ##
==========================================
+ Coverage 74.51% 74.54% +0.02%
==========================================
Files 70 70
Lines 39652 39642 -10
==========================================
+ Hits 29546 29550 +4
+ Misses 10106 10092 -14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
223e16b to
03b3fcf
Compare
|
@sylvestre friendly ping; is there anything I can do to make this PR easier to review? |
|
Getting that PR to be merged would unblock PyTorch's build of sccache on riscv64. See https://github.com/pytorch/pytorch/pull/182278/changes#diff-0a862d15a4e6dff44196719a594b983aece596c7dc38eba416d83e12a95206e6 for details |
|
having tests that cover this change would be helpful :) |
|
@rrbutani gentle ping on that issue? happy to have a look on adding tests a well. |
03b3fcf to
d90f112
Compare
|
Thanks for the ping, apologies for the delay. I've updated the existing The first commit in this PR has only these changes; running (for example)
@sylvestre Is ^ sufficient? |
currently this fails with: ``` [2026-07-30T20:04:59Z WARN sccache::dist::http::server] Res 2 error: run build failed, caused by: Compilation execution failed, caused by: Failed to enter a new Linux namespace, caused by: EPERM: Operation not permitted ``` this error comes from: ```rust nix::sched::unshare(nix::sched::CloneFlags::CLONE_NEWNS) ``` and is expected. --- The next commit will update `sccache-dist server` to run successfully without root.
… root the approach here is more or less the same as in mozilla#1628: use `CLONE_NEWUSER` (unprivileged user namespace) to be able to create a mount namespace + mount the overlayFS mounts without permissions unlike mozilla#1628, this PR leverages [`bubblewrap`'s overlay mount functionality](containers/bubblewrap@f371022) (added in `v0.11.0`) to create the overlayFS mounts at the `sccache-dist` → `bwrap` compile command process boundary. This has a couple of upsides: - sidesteps the [safety issues](https://github.com/mozilla/sccache/blob/9fb6a2542c0d2e82846252be19bb377e5ca8885b/src/bin/sccache-dist/build.rs#L447-L458) in mozilla#1628 caused by forking the `sccache-dist` process - avoids the [issue](mozilla#1688) with overlay fs mounts not being unmounted once the compile command finishes that ultimately led to mozilla#1628 being [reverted](mozilla#1689) + though, I think this issue was actually caused by mozilla#1628 changing the default sandboxing codepath (i.e. `current_ns`) to call `CLONE_NEWNS` [in the `sccache-dist`'s `rouille` request handler thread](https://github.com/mozilla/sccache/blob/9fb6a2542c0d2e82846252be19bb377e5ca8885b/src/bin/sccache-dist/build.rs#L422-L429) instead of [in the thread spawned for a compile](https://github.com/mozilla/sccache/blob/c72eed63d78c8550b93133e9fa461a0c6ef7a30d/src/bin/sccache-dist/build.rs#L272-L276) (and not anything to do with the unprivileged user namespace logic) other notes: - previously deleting the build directory/the per-compile directories did not run into permission issues because `sccache-dist` was running as root closes mozilla#326, closes mozilla#1660 closes mozilla#1688 supersedes mozilla#2706
2c9184b to
05bb9da
Compare
|
@sylvestre friendly ping |
Note
I've opened this PR to get feedback on whether the direction here is acceptable. There are still a few items that need to be addressed (see
pendingbelow) before this is ready for merge.The approach here is more or less the same as in #1628: use
CLONE_NEWUSER(unprivileged user namespace) to be able to create a mount namespace + mount the overlayFS mounts without permissionsUnlike #1628, this PR leverages
bubblewrap's overlay mount functionality (added inv0.11.0) to create the overlayFS mounts at thesccache-dist→bwrapcompile command process boundary. This has a couple of upsides:sccache-distprocesscurrent_ns) to callCLONE_NEWNSin thesccache-dist'srouillerequest handler thread instead of in the thread spawned for a compile (and not anything to do with the unprivileged user namespace logic)other notes:
sccache-distwas running as rootpending/open questions:
userxattr.overlayxattrs in the compile inputs tarball?bubblewraphandle creating the mountpoint this isn't an optiontar::Archivedefaults to not restoringxattrsso I think the only consideration is whiteouts?closes #326, closes #1660, closes #1688, supersedes #2706