-
Notifications
You must be signed in to change notification settings - Fork 68
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
Using services from other strata, a report of trying to do it with an overlay filesystem #190
Comments
If I'm following correctly, you're unioning
I don't think there's a way to cleanly and reliably get overlayfs to make the file visible to to some processes but not others. This is fine for personal use/experimentation, but I don't think it's good for a general Bedrock solution in the long run. Other potential problem is that some init systems do not differentiate between services that are (1) available but disabled by default and (2) services that are available and expected to be run on boot. If we're working toward a general solution for multiple init systems (e.g. runit, openrc, sysv, etc) this strategy would result in a lot of things starting at boot a user may not be interested in. Users don't have complete, obvious control over this as some things get pulled in as dependencies. My thought here is to make cross-stratum init configuration available at some Bedrock specific location (likely something like
Not to be pedantic, but I think you mean "local" here rather than "global." If they're "global" we're already good. The goal you have in mind here is likely to make them "cross."
This is exactly what's expected. In fact, it's also how Bedrock automatically handles related issues. Read the comments in My long term thought here is to make something like a
My current thoughts here are to group such systemd fields into one of the following categories:
Nice!
This is another thing Bedrock's crossfs solves. It populates things on-the-fly. Once files are available in a given stratum, their cross-stratum equivalent are immediately available in crossfs.
I think altering init configuration to be cross-stratum is going to be necessary, but I expect we can automate it, at least for simple cases. |
overlayfs will prioritize files in the upper dir, therefore no files from the main stratum should be replaced, they will only be placed there if they don't exist in the main one. Though indeed it will not isolate services from multiple strata from interacting with each other
I was thinking about at least allowing to unite services for at least one system if the strata has the same one. Making them all work together would require implementing a supervisor that replaces the system supervisor and proxies requests to do things to the child supervisor, at least that is how I think it would be, this may somehow be achived by putting xattrs on services from other strata and replacing paths to these files when the child init tries to access them, as well as paths to binaries they try to access. Though
may be a better idea.
You are right, what I meant is that they tried to access the path in the main stratum instead of the right one. For the rest of your post I can't add much, as it all seems to be a fairly good idea, though this still means an init daemon or some kind of wrapper for services will be needed. As for
I was able to automatically patch services on ubuntu with a simple post-install hook, but that will probably not be that easy with other package managers and if there is a different system for starting services / a different init daemon to sit on top be implemented, it may not be necessary. I've been thinking about it for a few days and things seem to be hard to do without somehow either patching the services or overriding/patching the init daemons. |
If you're stating this as a resolution to the problem I'm illustrating, I don't see how it resolves things at all. You'll still end up with a package manager error about a preexisting file which could easily surprise users. If you're not stating this as a resolution to the problem I'm illustrating, I'm even more lost as to what this is intended to express.
I don't know how service isolation came up here; this reads to me like a non-sequitur.
In principle, that's a reasonable feature to pursue if it's easier/faster than a more general one until a more general one is available. It's not clear to me that it's meaningfully easier or faster than the general approach I'm proposing.
I think I follow your broad plan to make a supervisor that wraps per-stratum supervisors, but I don't follow:
I see how broadly something like this could be done if we isolate the per-stratum inits, but that defeats the whole point of Bedrock. I don't see how to do something like this without isolating them.
👍
I don't follow how my proposal requires an init daemon or wrapper for simple services. I do see how something like systemd-shim is needed if we're going to run services that have a hard dependency systemd with non-systemd inits, if that's what you mean. AFAIK systemd-shim is dead, and I don't personally plan on reviving it, but if someone else did that'd be useful here.
Most Bedrock efforts try to use as generic a solution as possible. Package manager hooks are much more project-specific and don't scale very well; they're not an avenue I want to go down if I can avoid it. I also dislike patching stratum local files. This upsets package managers and makes the system even harder to administrate. Leave package manager owned files to their package managers. |
I'll rephrase my proposal, in case I wasn't sufficiently clear. First, background: One of the main strategies Bedrock currently uses is You noticed, correctly, that init configuration does not current work cross-stratum as is. You can't just copy/paste one stratum's init configuration into another stratum's init's configuration location and expect it to work. You also noticed that you can tweak init configuration to work cross-stratum, such as by injecting My proposal: Use crossfs to do these translations - things like injecting The other half of the puzzle is getting inits to know about these service configuration items in
My proposal here is to have users manually symlink cross-stratum init configuration items from Downsides to my proposal:
Upsides to my proposal:
|
Sorry, I guess I haven't been reading it properly. I think i get more or less what you mean now. This requires extending crossfs to understand these service files, right? With systemd, just parsing and replacing things would probably work fine, but for openrc scripts i'm not quite sure.. There are some special variables OpenRC uses for simple cases, but otherwise it's all just a shell script where an executable can be used anywhere. I've tried reading crossfs code but it's a bit too hard for me to understand just from glancing. Perhaps I'll try to work out some initial code for what you're proposing, at least to get to know the filesystem better. |
That's right.
My current thought is to do something like:
where the shell library contains OpenRC specific functions like Going in the other direction, it'd be something like:
However, I don't know OpenRC well at all, and I could be underestimating the difficulty. Runit should be the easiest here; they're just single
and going the other way would just be
There may be additional work needed to do to handle things like whether the service daemonizes or not. runit has My expectation is that an initial release here only supports the simplest of services. We'll then add init system feature translation over time.
What I wrote above was an explanation of where I'm thinking Bedrock goes, and not necessarily asking you to write this. crossfs is probably the hardest part of Bedrock's code base to understand, at least in part due to tweaking over time leading to tech debt rather than because it's optimal. If you want to pursue it, I'm A-okay with that, but if you don't that's fine to. I'm happy to do it once more pressing things are done. That having been said, it'll be a long while before I get to it. If you are pursuing it, my thought is to:
Having this generic intermediate representation means we just have to write (2 x init-system-count) functions instead of (init-system-count^2) functions. If you have your heart set on cross-stratum init work, I'm absolutely happy to receive assistance there. However, if you're just looking to contribute to Bedrock in general and you know C, there are two other tasks that I feel are a much higher priority than this one:
If you are interested in pursuing either of those but aren't sure how to reproduce the issue, I can provide more details. That having been said, Bedrock is all volunteer work: feel free to work on whatever task you have the most interest in, if any. |
I've drafted a base for what was discussed in #192. For now it just does more or less what I was doing by hand, except the user has to symlink things to their actual service directory to use them. |
I don't see value in going this route. If you just want to add
under
and you're good to go. Otherwise, if you want to set up infrastructure to handle things like selectively ignoring some fields (e.g. |
This is just a start for the rest of the things. I'll be working on the universal format for services next. The PR is far from done, hence it is a draft. |
Gotcha. Sounds good! |
I've tried some things to make services work across strata, and while it is not very satisfactory, i was able to do it to some degree.
Using overlayfs (has been built into the mainline kernel for some time) I mounted a directory that contained systemd units from another stratum over the current stratum's service directory. This made it so that current stratum's systemd would see these services, however the paths in them are still global. How to solve this isn't exactly clear, but i've had success with patching services by substituting
ExecStart=something
withExecStart=/bedrock/bin/strata -r (stratum) something
. However, some systemd "security features", namely SystemCallArchitecture, MemoryDenyWriteExecute and NoNewPreviledges make this fail to work unless disabled. This way, I was able to start thesyncthing@.unit
from another stratum. Another disappointing thing is that overlayfs has to be remounted every time something in the other strata changes, though it is pretty fast to do. This may not be the way forward, especially since it requires patching services to work, but I thought it would be good to place this here to show what has been tried.The text was updated successfully, but these errors were encountered: