-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macOS support #87
macOS support #87
Conversation
Do we really need to investigate if the rsync backend works fine or is zfs still used even with rsync? |
I was going to try and show using the Github runner that it is quite a bit slower but looks like it ran out of memory or something and I can't cancel the job :( Anyway, that's the main problem, rsync is slow. I used WSL to check the linux version worked and the stress test there says:
I can't imagine that's all WSL/virtualisation's fault :/ When I get a chance I'll see if I can port the stress test to macOS and then do a head to head with ZFS maybe. EDIT: Building directly in the directory gives
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable. Might be worth separating the rsync stuff out into a separate PR to make reviewing easier, but since that and the macos support is experimental it's not a big problem.
lib/os.ml
Outdated
let pp s ppf = Fmt.pf ppf "[ %s ]" s in | ||
if String.length pid = 0 then (Log.warn (fun f -> f "Empty PID"); Lwt.return ()) | ||
else begin | ||
let delete = ["kill"; "-9"; pid ] in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Linux, kill
says:
Negative PID values may be used to choose whole process groups; see the PGID column in ps command output.
Is that useful on macos too?
There's also setsid(1)
. I don't know much about this stuff, but I think it's the old POSIX way of managing groups of processes from before Linux had containers.
lib/rsync_store.ml
Outdated
let gen = cache.gen in | ||
Rsync.copy_children ~src:snapshot ~dst:tmp >>= fun () -> | ||
let { Obuilder_spec.uid; gid } = user in | ||
Os.sudo ["chown"; Printf.sprintf "%d:%d" uid gid; tmp] >>= fun () -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would probably be faster to do rsync --chown
above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change went into #88 but I've just realised that macOS ships with a much older version of rsync
that doesn't support --chown
. There are two options:
- Go back to this implementation so Obuilder will work with the default rsync macOS comes with.
- Force people to download a newer version -- note this is not necessarily super straightforward because
brew install rsync
will put it in/usr/local
and won't be available whenobuilderfs
is active, so the user will probably have to build from source and put the binary and libs elsewhere.
Any thoughts ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess we can revert that then. I'm not used to things being older than debian/stable! (and, indeed, older than debian/oldstable too!!)
Might be a performance hit, though. I remember that running sudo chown
in Dockerfiles is massively slower than setting the ownership in the COPY
.
This I have "solved" by having a |
bcab0da
to
45e811f
Compare
Thanks for the review @talex5 :)) I will investigate a cleaner |
Nested sandbox-exec is not permitted. When tried it returns:
It could be a good idea to enable sandboxing by default and to have some kind of parameter to disable it, e.g.
|
bc2f34a
to
0382e9a
Compare
ocurrent/ocluster#152 is now in opam-repo-ci as |
@@ -125,7 +125,9 @@ let cache ~user t name = | |||
(* Create writeable clone. *) | |||
let gen = cache.gen in | |||
let { Obuilder_spec.uid; gid } = user in | |||
Rsync.copy_children ~chown:(Printf.sprintf "%d:%d" uid gid) ~src:snapshot ~dst:tmp () >>= fun () -> | |||
(* rsync --chown not supported by the rsync that macOS ships with *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn’t rsync
be using -a
(which includes -o
and -g
, aka. preserve owner/group) instead of plain rsync + chown? It should be more efficient.
Or are there some issues with owner/group needing changing between 2 snapshots?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default all rsync
commands have -aHq
Line 27 in ea78b35
let rsync = [ "rsync"; "-aHq" ] |
The extra chown
iiuc is for differences between uids/gids when restoring caches. It is not used in macOS where we ignore the config.user
because we're using users
to build, unlike in runc where it could be anyone
Lines 110 to 115 in ea78b35
let user = | |
let { Obuilder_spec.uid; gid } = user in | |
`Assoc [ | |
"uid", `Int uid; | |
"gid", `Int gid; | |
] |
Just adding an update here that this PR now uses "a static home directory", this is needed to avoid relocation errors (the OCaml compiler is not relocatable, nor are quite a few packages). This comes at the expense of 2 additional copies from and to the static home directory. A typical build step is now:
The extra copies do slow down each build step. An alternative solution that could be explored would be to |
200580c
to
9c910f0
Compare
Co-authored-by: Kate <[email protected]>
Closing in favour of #122 |
CHANGES: - Add --fuse-path to allow selection of the path redirected by FUSE (@mtelvers ocurrent/obuilder#128, reviewed by @MisterDA ) - Pre-requisites for Windows support using docker for Windows (@MisterDA ocurrent/obuilder#116, reviewed by @tmcgilchrist) - Additional tests and prerequistes for Windows support (@MisterDA ocurrent/obuilder#130, reviewed by @tmcgilchrist) - Add support for Docker/Windows spec (@MisterDA ocurrent/obuilder#117, reviewed by @tmcgilchrist) - Depend on Lwt.5.6.1 for bugfixes (@MisterDA ocurrent/obuilder#108, reviewed by @tmcgilchrist) - Add macOS support (@patricoferris ocurrent/obuilder#87, reviewed by @tmcgilchrist @talex5 @kit-ty-kate) - Enable macOS tests only on macOS (@MisterDA ocurrent/obuilder#126, reviewed by @tmcgilchrist) - Dune 3.0 generates empty intf for executables (@MisterDA ocurrent/obuilder#111, reviewed by @talex5) - Fix warnings and CI failure (@MisterDA ocurrent/obuilder#110, reviewed by @talex5) - Expose store root and cmdliner term with non-required store (@MisterDA ocurrent/obuilder#119, reviewed by @tmcgilchrist) - Expose Rsync_store module (@MisterDA ocurrent/obuilder#114, reviewed by @talex5) - Rsync hard-links to save space (@art-w ocurrent/obuilder#102, reviewed by @patricoferris)
This PR is a draft for initial macOS support using users as sandboxes. This PR contains:
macos_sandbox.ml
implementation which generates a new user and executes commands as the user, note at this time obuilder only expects a single user to be run at a time.This PR is a re-branding of this branch that was proving to difficult to rebase and also the commit history was a bit wonky. To get in this "working" state I had a lot of help from @kit-ty-kate and @talex5, thanks!
Questions
result
andresult-tmp
directory and can quickly copy from one to the other with snapshotting. ZFS (due to limitations) builds directly in the result directory. I'm wondering if rsync should do the same which should make it significantly faster.sandbox-exec
everything, not sure how nicely that plays when nested (whenopam
invokes it).User_temp.ml
could probably just be removed now, everything can use the "Docker fetcher" or would it be good to support a file-path based fetch (not limited to/Users
) just sometar:/path/to/tar
, it can be useful on macOS for testing but not strictly necessary ?TODOs
mac-cat-2
inopam-repo-ci
and running aopam-health-check
with the latest version of all packages too.