[lxc-devel] [lxd/master] lxd/containers: Respect raw.lxc on stop/shutdown

stgraber on Github lxc-bot at linuxcontainers.org
Fri Sep 20 10:15:04 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190920/df408f19/attachment.bin>
-------------- next part --------------
From c497e53dc064bc467652a620d950caf7280f1749 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 20 Sep 2019 12:14:43 +0200
Subject: [PATCH] lxd/containers: Respect raw.lxc on stop/shutdown
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: St├ęphane Graber <stgraber at ubuntu.com>
---
 lxd/container_lxc.go | 38 ++++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 93b7beaf06..67e2e5f2d6 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -2864,11 +2864,20 @@ func (c *containerLXC) Stop(stateful bool) error {
 	}
 
 	// Load the go-lxc struct
-	err = c.initLXC(false)
-	if err != nil {
-		op.Done(err)
-		logger.Error("Failed stopping container", ctxMap)
-		return err
+	if c.expandedConfig["raw.lxc"] != "" {
+		err = c.initLXC(true)
+		if err != nil {
+			op.Done(err)
+			logger.Error("Failed stopping container", ctxMap)
+			return err
+		}
+	} else {
+		err = c.initLXC(false)
+		if err != nil {
+			op.Done(err)
+			logger.Error("Failed stopping container", ctxMap)
+			return err
+		}
 	}
 
 	// Fork-bomb mitigation, prevent forking from this point on
@@ -2935,11 +2944,20 @@ func (c *containerLXC) Shutdown(timeout time.Duration) error {
 	logger.Info("Shutting down container", ctxMap)
 
 	// Load the go-lxc struct
-	err = c.initLXC(false)
-	if err != nil {
-		op.Done(err)
-		logger.Error("Failed shutting down container", ctxMap)
-		return err
+	if c.expandedConfig["raw.lxc"] != "" {
+		err = c.initLXC(true)
+		if err != nil {
+			op.Done(err)
+			logger.Error("Failed stopping container", ctxMap)
+			return err
+		}
+	} else {
+		err = c.initLXC(false)
+		if err != nil {
+			op.Done(err)
+			logger.Error("Failed stopping container", ctxMap)
+			return err
+		}
 	}
 
 	if err := c.c.Shutdown(timeout); err != nil {


More information about the lxc-devel mailing list