dist: use bubblewrap for overlayFS mounts, run sccache-dist without root#2728
Open
rrbutani wants to merge 1 commit into
Open
dist: use bubblewrap for overlayFS mounts, run sccache-dist without root#2728rrbutani wants to merge 1 commit into
sccache-dist without root#2728rrbutani wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2728 +/- ##
==========================================
+ Coverage 73.38% 74.53% +1.14%
==========================================
Files 70 70
Lines 39379 39642 +263
==========================================
+ Hits 28900 29548 +648
+ Misses 10479 10094 -385 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… 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
223e16b to
03b3fcf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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