[lxc-devel] [lxd/master] lxc/copy: Updates copyContainer to not modify volatile.idmap.next
tomponline on Github
lxc-bot at linuxcontainers.org
Wed Dec 4 15:36:47 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 361 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191204/c81bc37a/attachment.bin>
-------------- next part --------------
From 9eefc91ea0f0a452d861273e59969554183a9513 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 4 Dec 2019 15:34:51 +0000
Subject: [PATCH] lxc/copy: Updates copyContainer to not modify
volatile.idmap.next
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxc/copy.go | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/lxc/copy.go b/lxc/copy.go
index eccbd0bf16..9998e7f2ac 100644
--- a/lxc/copy.go
+++ b/lxc/copy.go
@@ -59,9 +59,7 @@ func (c *cmdCopy) Command() *cobra.Command {
return cmd
}
-func (c *cmdCopy) copyContainer(conf *config.Config, sourceResource string,
- destResource string, keepVolatile bool, ephemeral int, stateful bool,
- containerOnly bool, mode string, pool string, move bool) error {
+func (c *cmdCopy) copyContainer(conf *config.Config, sourceResource string, destResource string, keepVolatile bool, ephemeral int, stateful bool, containerOnly bool, mode string, pool string, move bool) error {
// Parse the source
sourceRemote, sourceName, err := conf.ParseRemote(sourceResource)
if err != nil {
@@ -372,11 +370,16 @@ func (c *cmdCopy) copyContainer(conf *config.Config, sourceResource string,
progress.Done("")
if c.flagRefresh {
- _, etag, err := dest.GetInstance(destName)
+ inst, etag, err := dest.GetInstance(destName)
if err != nil {
return fmt.Errorf("Failed to refresh target container '%s': %v", destName, err)
}
+ // Ensure we don't change the target's volatile.idmap.next value.
+ if inst.Config["volatile.idmap.next"] != "" {
+ writable.Config["volatile.idmap.next"] = inst.Config["volatile.idmap.next"]
+ }
+
op, err := dest.UpdateInstance(destName, writable, etag)
if err != nil {
return err
@@ -474,11 +477,9 @@ func (c *cmdCopy) Run(cmd *cobra.Command, args []string) error {
// If not target name is specified, one will be chosed by the server
if len(args) < 2 {
- return c.copyContainer(conf, args[0], "", keepVolatile, ephem,
- stateful, instanceOnly, mode, c.flagStorage, false)
+ return c.copyContainer(conf, args[0], "", keepVolatile, ephem, stateful, instanceOnly, mode, c.flagStorage, false)
}
// Normal copy with a pre-determined name
- return c.copyContainer(conf, args[0], args[1], keepVolatile, ephem,
- stateful, instanceOnly, mode, c.flagStorage, false)
+ return c.copyContainer(conf, args[0], args[1], keepVolatile, ephem, stateful, instanceOnly, mode, c.flagStorage, false)
}
More information about the lxc-devel
mailing list