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

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) ===
Closes #6551

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 1dcd9e7e5aef3e9593645c05977dc09f9286fd41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 4 Dec 2019 20:53:25 -0500
Subject: [PATCH] lxc/storage: Fix template apply on cross-pool copy
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6551

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/storage_btrfs.go |  7 ++++++-
 lxd/storage_ceph.go  |  7 ++++++-
 lxd/storage_zfs.go   | 17 +++++++++++------
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index cda37f1f7e..932e17b363 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -1158,7 +1158,12 @@ func (s *storageBtrfs) ContainerCopy(target 
instance.Instance, source instance.I
        _, sourcePool, _ := srcCt.Storage().GetContainerPoolInfo()
        _, targetPool, _ := targetCt.Storage().GetContainerPoolInfo()
        if sourcePool != targetPool {
-               return s.doCrossPoolContainerCopy(target, source, 
containerOnly, false, nil)
+               err = s.doCrossPoolContainerCopy(target, source, containerOnly, 
false, nil)
+               if err != nil {
+                       return err
+               }
+
+               return target.DeferTemplateApply("copy")
        }
 
        err = s.copyContainer(target, source)
diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index 30be16af00..cb39f0a72c 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -1118,7 +1118,12 @@ func (s *storageCeph) ContainerCopy(target 
instance.Instance, source instance.In
        _, sourcePool, _ := srcCt.Storage().GetContainerPoolInfo()
        _, targetPool, _ := targetCt.Storage().GetContainerPoolInfo()
        if sourcePool != targetPool {
-               return s.doCrossPoolContainerCopy(target, source, 
containerOnly, false, nil)
+               err := s.doCrossPoolContainerCopy(target, source, 
containerOnly, false, nil)
+               if err != nil {
+                       return err
+               }
+
+               return target.DeferTemplateApply("copy")
        }
 
        revert := true
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index 05f5ebadce..5b15d6694a 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -1021,11 +1021,6 @@ func (s *storageZfs) copyWithoutSnapshotsSparse(target 
instance.Instance, source
                }
        }
 
-       err := target.DeferTemplateApply("copy")
-       if err != nil {
-               return err
-       }
-
        revert = false
 
        return nil
@@ -1282,7 +1277,12 @@ func (s *storageZfs) ContainerCopy(target 
instance.Instance, source instance.Ins
        _, sourcePool, _ := srcCt.Storage().GetContainerPoolInfo()
        _, targetPool, _ := targetCt.Storage().GetContainerPoolInfo()
        if sourcePool != targetPool {
-               return s.doCrossPoolContainerCopy(target, source, 
containerOnly, false, nil)
+               err := s.doCrossPoolContainerCopy(target, source, 
containerOnly, false, nil)
+               if err != nil {
+                       return err
+               }
+
+               return target.DeferTemplateApply("copy")
        }
 
        snapshots, err := source.Snapshots()
@@ -1391,6 +1391,11 @@ func (s *storageZfs) ContainerCopy(target 
instance.Instance, source instance.Ins
                }
        }
 
+       err = target.DeferTemplateApply("copy")
+       if err != nil {
+               return err
+       }
+
        logger.Debugf("Copied ZFS container storage %s to %s", source.Name(), 
target.Name())
        return nil
 }
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to