[lxc-devel] [lxd/master] lxd/containers: Push MAAS entry after dev creation

stgraber on Github lxc-bot at linuxcontainers.org
Wed Oct 30 14:39:48 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191030/8049bf64/attachment.bin>
-------------- next part --------------
From dbbd500f4751c944abe58fea04011608e6752994 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 30 Oct 2019 15:38:26 +0100
Subject: [PATCH] lxd/containers: Push MAAS entry after dev creation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6366

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/container_lxc.go | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index e03d65c92c..76e1f36960 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -416,14 +416,6 @@ func containerLXCCreate(s *state.State, args db.InstanceArgs) (container, error)
 	}
 
 	if !c.IsSnapshot() {
-		// Update MAAS
-		err = c.maasUpdate(nil)
-		if err != nil {
-			c.Delete()
-			logger.Error("Failed creating container", ctxMap)
-			return nil, err
-		}
-
 		// Add devices to container.
 		for k, m := range c.expandedDevices {
 			err = c.deviceAdd(k, m)
@@ -432,6 +424,14 @@ func containerLXCCreate(s *state.State, args db.InstanceArgs) (container, error)
 				return nil, errors.Wrapf(err, "Failed to add device '%s'", k)
 			}
 		}
+
+		// Update MAAS
+		err = c.maasUpdate(nil)
+		if err != nil {
+			c.Delete()
+			logger.Error("Failed creating container", ctxMap)
+			return nil, err
+		}
 	}
 
 	logger.Info("Created container", ctxMap)


More information about the lxc-devel mailing list