[lxc-devel] [lxd/master] Properly invalidate the idmap cache

stgraber on Github lxc-bot at linuxcontainers.org
Tue Apr 18 06:05:33 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 476 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170418/913d2f09/attachment.bin>
-------------- next part --------------
From 73a2651e21b0fe87f5971508354e3c6049abea36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 18 Apr 2017 02:04:32 -0400
Subject: [PATCH] Properly invalidate the idmap cache
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Without this we'd run the risk of changing idmap values and then doing
an action like a publish with an incorect map.

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

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index c5e7c0e..52dfbec 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -316,6 +316,9 @@ func containerLXCCreate(d *Daemon, args containerArgs) (container, error) {
 		return nil, err
 	}
 
+	// Invalid idmap cache
+	c.idmapset = nil
+
 	// Set last_state to the map we have on disk
 	if c.localConfig["volatile.last_state.idmap"] == "" {
 		err = c.ConfigKeySet("volatile.last_state.idmap", jsonIdmap)
@@ -3281,6 +3284,9 @@ func (c *containerLXC) Update(args containerArgs, userRequested bool) error {
 		}
 		c.localConfig["volatile.idmap.next"] = jsonIdmap
 		c.localConfig["volatile.idmap.base"] = fmt.Sprintf("%v", base)
+
+		// Invalid idmap cache
+		c.idmapset = nil
 	}
 
 	// Retrieve old root disk devices.


More information about the lxc-devel mailing list