Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 556826 - app-emulation/lxc: /etc/init.d/lxc stop stops the LXC twice
Summary: app-emulation/lxc: /etc/init.d/lxc stop stops the LXC twice
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Diego Elio Pettenò (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-06 09:35 UTC by Killian De Volder
Modified: 2015-09-05 07:04 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Killian De Volder 2015-08-06 09:35:04 UTC
The following command sequence is ran:

init_pid=$(lxc-info -n ${CONTAINER} --pid | awk '{ print $2 }')
kill -PWR ${init_pid}
<wait for pid to die>

lxc-stop -n ${CONTAINER}

However lxc-stop will complain the container is no longer started, because it has been killed before. Followed of course by the service being stuck.

Would be probably be fixed if https://530896.bugs.gentoo.org/ is fixed.

Reproducible: Always

Steps to Reproduce:
1. Create a very fast LXC.
2. /etc/init.d/lxc.myfast start
3. /etc/init.d/lxc.myfast stop
Comment 1 Markos Chandras (RETIRED) gentoo-dev 2015-09-02 18:40:03 UTC
I find the existing shutdown code rather obscure. Does that patch work for you?

diff --git a/app-emulation/lxc/files/lxc.initd.3 b/app-emulation/lxc/files/lxc.initd.3
index c9ef999..b9d8c14 100644
--- a/app-emulation/lxc/files/lxc.initd.3
+++ b/app-emulation/lxc/files/lxc.initd.3
@@ -111,29 +111,8 @@ stop() {
            return 0
        fi
 
-       init_pid=$(lxc-info -n ${CONTAINER} --pid | awk '{ print $2 }')
-
-       if [ -z "${init_pid}" ]; then
-           ewarn "${CONTAINER} doesn't seem to be running."
-           return 0
-       fi
-
-       ebegin "Shutting down system in ${CONTAINER}"
-       kill -PWR ${init_pid}
-       eend $?
-
-       TIMEOUT=${TIMEOUT:-30}
-       i=0
-       while [ -n "$(pgrep -P ${init_pid})" -a $i -lt ${TIMEOUT} ]; do
-               sleep 1
-               i=$(expr $i + 1)
-       done
-
-       if [ -n "${missingprocs}" ]; then
-               ewarn "Something failed to properly shut down in ${CONTAINER}"
-       fi
-
+       # 10s should be enough to shut everything down
        ebegin "Stopping ${CONTAINER}"
-       lxc-stop -n ${CONTAINER}
+       lxc-stop -t 30 -n ${CONTAINER}
        eend $?
Comment 2 Markos Chandras (RETIRED) gentoo-dev 2015-09-05 07:04:07 UTC
I committed that fix