[lxc-devel] [lxd/master] lxc/storage: Fix template apply on cross-pool copy

stgraber on Github lxc-bot at linuxcontainers.org
Thu Dec 5 01:54:31 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/20191204/f07896a4/attachment.bin>
-------------- next part --------------
From 1dcd9e7e5aef3e9593645c05977dc09f9286fd41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at 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 <stgraber at 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
 }


More information about the lxc-devel mailing list