Skip to content
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

pass VIRTUALIZATION var to runsvdir for scripts #102

Closed
wants to merge 1 commit into from

Conversation

sbromberger
Copy link

This fixes the issues identified in #101 where the VIRTUALIZATION environment variable exported in /etc/runit/1 is not available to runsv scripts. Allowing this will permit runsv services to do different things based on whether they're running in a container or not. (See void-linux/void-packages#41273 for an example of when this would be needed - this PR needs some modifications but it will be able to use this variable to determine which setup commands to run.)

Supersedes and obviates #101

This fixes the issues identified in #101 where the `VIRTUALIZATION` environment variable exported in `/etc/runit/1` is not available to runsv scripts. Allowing this will permit runsv services to do different things based on whether they're running in a container or not. (See void-linux/void-packages#41273 for an example of when this would be needed - this PR needs some modifications but it will be able to use this variable to determine which setup commands to run.)
@sbromberger
Copy link
Author

cc @CameronNemo

@Duncaen
Copy link
Member

Duncaen commented Dec 24, 2022

I don't like exporting that variable, this is not a standard and we shouldn't have to invent things and then depend on just for one service run script. The run script could just be changed to not exit if modprobe fails or use some other command to check if the module is loaded first and otherwise try modprobe and exit.

@sbromberger
Copy link
Author

sbromberger commented Dec 25, 2022

The run script could just be changed to not exit if modprobe fails or use some other command to check if the module is loaded first and otherwise try modprobe and exit.

That's what I had originally (void-linux/void-packages#41272) but it turns out that you also need a different cgroups mount if you're in a container. You can put it in /etc/rc.local but that can't be part of the install process and needs to be documented somewhere.

Having a way for runsv to determine whether or not you're in a container is really useful.

@CameronNemo
Copy link
Contributor

@sbromberger cgroups mounting is handled in this repo, in the pseudofs "core service".

@sbromberger
Copy link
Author

@Duncaen - Is it your recommendation that we re-implement the functionality of detect_virt within the runsv scripts that require it by grepping through /proc/1/environ ? This seems a bit wasteful when the work has already been done in 1, but I can certainly modify the run script to do this.

@sbromberger
Copy link
Author

sbromberger commented Dec 25, 2022

@CameronNemo this is a special cgroups mount for docker: https://github.com/void-linux/void-packages/blob/7ac4f42d9795a6bd0e8c523fd70cb6ab9fe902fc/srcpkgs/moby/files/docker/run#L6 is the way it's currently done, but this doesn't work in containers: you need mount -t cgroup2 cgroup2 /sys/fs/cgroup/ instead.

@CameronNemo
Copy link
Contributor

#103 before I lose my train of thought

@CameronNemo
Copy link
Contributor

relevant past discussion: void-linux/void-docs#151 (comment)

@sbromberger sbromberger closed this by deleting the head repository Aug 17, 2024
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.

3 participants