void-linux / runit

The init system for Void Linux.
https://voidlinux.org
160 stars 22 forks source link

Handle SIGPWR signal (shutdown) #2

Open Anachron opened 5 years ago

Anachron commented 5 years ago

LXC/LXD sends sigpwr signal to Pid 1 but it doesn‘t listen to it, thus stopping LXC/LXD from stopping the container correctly.

Anachron commented 5 years ago

There is already a patch for runit to react on SIGPWR here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923924

faulesocke commented 5 years ago

I believe this is the wrong repository for the issue, open one in https://github.com/void-linux/void-packages/ or directly file a PR there.

CameronNemo commented 4 years ago

This should be moved to https://github.com/void-linux/runit . @ericonr

ericonr commented 3 years ago

For the pretty patch from Debian, see here

Duncaen commented 3 years ago

Regarding the debian patch, here is my comment from another issue:

I'm not completely happy with it, I would like to have a mechanism to completely disable sigpwr for non containers and users who may run a UPS that sends sigpwr but don't want this to shutdown the system or handle in some other way.

This also requires man page updates, we shouldn't just change how init behaves when it is signaled without documenting it and considering edge cases.

I would add /etc/runit/sigpwr which is checked for for existence and executable bit. Create it from our core services, and chmod u+x it if it is a "container" system.

This would not change anything for normal users, introduce the wanted behavior for "containers" and allows users with USPs that send a signal to pid 1 to enable it by chmod u+x the file.

https://github.com/void-linux/void-packages/pull/20098#issuecomment-601189877

ghost commented 3 years ago

A working Hotfix (if you're not relying on SIGCONT being sent to init) (for example, for embedding into the lxc template hook):

Set the executable flag on /etc/runit/stopit and add lxc.signal.halt = SIGCONT to the lxc configuration file: setting the executable flag causes runit to shutdown on SIGCONT, and the configuration addition causes LXC to send SIGCONT signals instead of SIGPWR on non-forced shutdown requests (like the ones by lxc-stop).

Because /etc/runit/stopit is just a symlink to /run/runit/stopit (which in turn is not persistent over reboots), you have set the +x flag on every reboot. This could be done easily by something like appending chmod +x /run/runit/stopit to /etc/rc.local.

I have no idea what this might break though.

amak79 commented 2 years ago

The upstream LXC/LXD Void image now modifies /etc/runit/1 to set the mode for /run/runit/stopit to 100. Unfortunately this won't survive an update to the runit-void package, so using /etc/rc.local to change the mode is still needed.

In a similar way to LXC, LXD users will also need to change the signal with lxc config set <instance> raw.lxc lxc.signal.halt=SIGCONT.