Discussion:
[lxc-devel] [lxd/master] Properly invalidate the idmap cache
stgraber on Github
2017-04-18 06:05:34 UTC
Permalink
From 73a2651e21b0fe87f5971508354e3c6049abea36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <***@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 <***@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.

Loading...