I am running a LXD cluster with four nodes on gentoo. I am using OpenRC as init system. I noticed that all containers in a cluster are stopped if I restart one node. Reproducible: Always Steps to Reproduce: 1. Build a LXD cluster 2. distribute containers on LXD nodes 3. shutdown/reboot a node Actual Results: All containers in the cluster are stopped. Expected Results: Cluster on other nodes shouldn't stopped on shutdown of a single node. I was able to trace it back to the following lines in the openrc init script: lxc stop --all --timeout $TIMEOUT >/dev/null 2>&1 if [[ ${?} -ne 0 ]]; then lxc stop --all --force || eerror "Could not stop all containers." fi lxc stop --all does affect all containers an all nodes. Those four lines should be removed, because the following "lxd shutdown" already stops only local containers.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9f88706ccb6f6582b42ff558d679ebe39bc6fb93 commit 9f88706ccb6f6582b42ff558d679ebe39bc6fb93 Author: Joonas Niilola <juippis@gentoo.org> AuthorDate: 2021-02-16 08:27:59 +0000 Commit: Joonas Niilola <juippis@gentoo.org> CommitDate: 2021-02-16 08:29:42 +0000 app-emulation/lxd: don't shutdown all cluster instances with service Closes: https://bugs.gentoo.org/770511 Signed-off-by: Joonas Niilola <juippis@gentoo.org> app-emulation/lxd/files/lxd-4.0.0.initd | 25 +++------------------- .../{lxd-4.0.4-r5.ebuild => lxd-4.0.4-r6.ebuild} | 0 2 files changed, 3 insertions(+), 22 deletions(-)
This should do it, seems to work for me.
Close. But now containers are not shutdown safely on system shutdown/restart. On system restart/shutdown ([[ ${RC_GOINGDOWN} = YES ]] || [[ ${RC_REBOOT} = YES ]]) "lxd shutdown" should be executed to inform init systems in containers.
(In reply to Ogelpre from comment #3) > Close. But now containers are not shutdown safely on system > shutdown/restart. What problems does this bring? I haven't noticed anything weird yet. Would this work ok? diff --git a/app-emulation/lxd/files/lxd-4.0.0.initd b/app-emulation/lxd/files/lxd-4.0.0.initd index 1cd4da1840b..baec86805c6 100644 --- a/app-emulation/lxd/files/lxd-4.0.0.initd +++ b/app-emulation/lxd/files/lxd-4.0.0.initd @@ -29,8 +29,12 @@ start() { } stop() { - ebegin "Stopping lxd service (but not containers)." - start-stop-daemon --stop --quiet -R TERM/45 -p ${PIDFILE} - rm -f ${PIDFILE} - eend ${?} + if [[ ${RC_GOINGDOWN} = YES ]] || [[ ${RC_REBOOT} = YES ]]; then + "${DAEMON}" shutdown + rm -f ${PIDFILE} + else + ebegin "Stopping lxd service (but not containers)." + start-stop-daemon --stop --quiet -R TERM/45 -p ${PIDFILE} + eend ${?} + fi }
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=43b0f09708ca0ee5fb22bec6f3c5320b26c8b535 pushed the proposal, it works just as good to me as the previous one.
This change works. The difference is the following: If you upgrade LXD you can kill the daemon and start again. (restart daemon without stopping containers) The containers will keep running and the new LXD process will recognize the running containers. The containers will not restarted. If you do a lxd shutdown all containers will be shut. seamless upgrading of LXD is not possible. Alternatively we could implement a "reload" option which will restart LXD without shutting down containers.
Thanks for confirming. I'm up for any changes to init.d scripts if they are provided, as I'm using openrc on my main desktop with lxd, and would not want to break it for testing. I think we're pretty much the only distro running lxd with openrc out there so no help from neighbours?
Created attachment 687213 [details, diff] rework on openrc init script Alpine Linux uses OpenRC, too. But they have just a minimal configuration: https://git.alpinelinux.org/aports/tree/testing/lxd/lxd.initd In LXD manuals I found information about the daemon behavior on different signals: https://lxd.readthedocs.io/en/latest/daemon-behavior/ Based on that information I did a rework of the init script and attached it.
Created attachment 687216 [details, diff] Updated patch for openrc init scripts Sorry, I had messed up ebgin messages. Should be fixed now.
Thank you! I will run this for a day or two and if nothing weird shows up, merge.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6ea96b2080d0903324e22a39400d23f1c7e1f71c commit 6ea96b2080d0903324e22a39400d23f1c7e1f71c Author: Benedikt Neuffer <gentoo@itfriend.de> AuthorDate: 2021-02-17 09:54:29 +0000 Commit: Joonas Niilola <juippis@gentoo.org> CommitDate: 2021-02-18 17:35:01 +0000 app-emulation/lxd: use signals in openrc script Rework on openrc script to use signals to communicate with the LXD daemon. Bug: https://bugs.gentoo.org/770511 Package-Manager: Portage-3.0.14, Repoman-3.0.2 Signed-off-by: Benedikt Neuffer <ogelpre@itfriend.de> Closes: https://bugs.gentoo.org/770511 Signed-off-by: Joonas Niilola <juippis@gentoo.org> app-emulation/lxd/files/lxd-4.0.0.initd | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) Additionally, it has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6ea96b2080d0903324e22a39400d23f1c7e1f71c commit 6ea96b2080d0903324e22a39400d23f1c7e1f71c Author: Benedikt Neuffer <gentoo@itfriend.de> AuthorDate: 2021-02-17 09:54:29 +0000 Commit: Joonas Niilola <juippis@gentoo.org> CommitDate: 2021-02-18 17:35:01 +0000 app-emulation/lxd: use signals in openrc script Rework on openrc script to use signals to communicate with the LXD daemon. Bug: https://bugs.gentoo.org/770511 Package-Manager: Portage-3.0.14, Repoman-3.0.2 Signed-off-by: Benedikt Neuffer <ogelpre@itfriend.de> Closes: https://bugs.gentoo.org/770511 Signed-off-by: Joonas Niilola <juippis@gentoo.org> app-emulation/lxd/files/lxd-4.0.0.initd | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)