The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6548

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
From 9eefc91ea0f0a452d861273e59969554183a9513 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@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.parr...@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)
 }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to