[lxc-devel] [lxc/master] start.c: do not reboot on lxc.hook.post-stop fail

brauner on Github lxc-bot at linuxcontainers.org
Tue Mar 1 09:45:26 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 638 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160301/edb0b374/attachment.bin>
-------------- next part --------------
From 9ea3a0db93a5927a7ad9ba0aeb90d23ce1089f4c Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at mailbox.org>
Date: Tue, 1 Mar 2016 10:42:45 +0100
Subject: [PATCH] start.c: do not reboot on lxc.hook.post-stop fail

lxc should not reboot the container when lxc.hook.post-stop fails. It should
simply shutdown. This makes the behavior of lxc.hook.post-stop and
lxc.hook.pre-start consistent. When lxc.hook.pre-start fails, the container
does not start.

Signed-off-by: Christian Brauner <christian.brauner at mailbox.org>
---
 src/lxc/start.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/lxc/start.c b/src/lxc/start.c
index 6a3ab95..0c029d8 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -546,8 +546,14 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
 	}
 	lxc_set_state(name, handler, STOPPED);
 
-	if (run_lxc_hooks(name, "post-stop", handler->conf, handler->lxcpath, NULL))
+	if (run_lxc_hooks(name, "post-stop", handler->conf, handler->lxcpath, NULL)) {
 		ERROR("failed to run post-stop hooks for container '%s'.", name);
+		if (handler->conf->reboot) {
+			WARN("Container will be stopped instead of rebooted.");
+			handler->conf->reboot = 0;
+			setenv("LXC_TARGET", "stop", 1);
+		}
+	}
 
 	/* reset mask set by setup_signal_fd */
 	if (sigprocmask(SIG_SETMASK, &handler->oldmask, NULL))


More information about the lxc-devel mailing list