[lxc-devel] [lxd/master] lxc/copy: Always strip volatile.last_state.power
stgraber on Github
lxc-bot at linuxcontainers.org
Mon Jun 24 20:41:47 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/20190624/697e8529/attachment.bin>
-------------- next part --------------
From 9c17bdb75dfeb91a70702218c69095bbefa5bc04 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 24 Jun 2019 16:00:04 -0400
Subject: [PATCH] lxc/copy: Always strip volatile.last_state.power
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #5759
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxc/copy.go | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/lxc/copy.go b/lxc/copy.go
index 5e1b5c05c6..da97460c90 100644
--- a/lxc/copy.go
+++ b/lxc/copy.go
@@ -221,15 +221,20 @@ func (c *cmdCopy) copyContainer(conf *config.Config, sourceResource string,
}
}
- // Strip the volatile keys if requested
- if !keepVolatile {
- for k := range entry.Config {
- if k == "volatile.base_image" {
- continue
- }
-
- if strings.HasPrefix(k, "volatile") {
- delete(entry.Config, k)
+ if entry.Config != nil {
+ // Strip the last_state.power key in all cases
+ delete(entry.Config, "volatile.last_state.power")
+
+ if !keepVolatile {
+ // Strip all volatile keys
+ for k := range entry.Config {
+ if k == "volatile.base_image" {
+ continue
+ }
+
+ if strings.HasPrefix(k, "volatile") {
+ delete(entry.Config, k)
+ }
}
}
}
More information about the lxc-devel
mailing list