[lxc-devel] [lxd/master] lxd/storage/zfs: Fix migration on zfs 0.6

stgraber on Github lxc-bot at linuxcontainers.org
Wed Nov 20 17:39:24 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/20191120/753a5fcb/attachment.bin>
-------------- next part --------------
From 051f3ecc9e8ec4780707ae0368dbacdaa1a9e81e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 20 Nov 2019 12:38:45 -0500
Subject: [PATCH] lxd/storage/zfs: Fix migration on zfs 0.6
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6478

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage_zfs.go | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index 26c5b4af2d..6685410db8 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -2567,7 +2567,7 @@ func (s *storageZfs) MigrationSink(conn *websocket.Conn, op *operations.Operatio
 	zfsName := fmt.Sprintf("containers/%s", project.Prefix(args.Instance.Project(), args.Instance.Name()))
 	zfsRecv := func(zfsName string, writeWrapper func(io.WriteCloser) io.WriteCloser) error {
 		zfsFsName := fmt.Sprintf("%s/%s", poolName, zfsName)
-		args := []string{"receive", "-F", "-o", "canmount=noauto", "-o", "mountpoint=none", "-u", zfsFsName}
+		args := []string{"receive", "-F", "-u", zfsFsName}
 		cmd := exec.Command("zfs", args...)
 
 		stdin, err := cmd.StdinPipe()
@@ -2599,8 +2599,20 @@ func (s *storageZfs) MigrationSink(conn *websocket.Conn, op *operations.Operatio
 		err = cmd.Wait()
 		if err != nil {
 			logger.Errorf("Problem with zfs recv: %s", string(output))
+			return err
 		}
-		return err
+
+		err = zfsPoolVolumeSet(poolName, zfsName, "canmount", "noauto")
+		if err != nil {
+			return err
+		}
+
+		err = zfsPoolVolumeSet(poolName, zfsName, "mountpoint", "none")
+		if err != nil {
+			return err
+		}
+
+		return nil
 	}
 
 	// Destroy the pre-existing (empty) dataset, this avoids issues with encryption


More information about the lxc-devel mailing list