The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7379
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) === Unified image VM unpack was not working for dir and btrfs drivers because the rsync of unpacked config files was removing the generated rootfs block file that was generated. This was silently failing because subsequently the storage driver attempted to set the generated volume to the correct size, and as it was missing, just generated a new blank image of the correct size. However the resulting VM was unbootable.
From 51b8879f617926ca57a5c543a57ee53385bce77d Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Mon, 18 May 2020 13:20:48 +0100 Subject: [PATCH 1/2] lxd/rsync: Adds optional rsync arguments to LocalCopy Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/rsync/rsync.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lxd/rsync/rsync.go b/lxd/rsync/rsync.go index 6b18c743e1..8f811ff4f8 100644 --- a/lxd/rsync/rsync.go +++ b/lxd/rsync/rsync.go @@ -19,7 +19,7 @@ import ( ) // LocalCopy copies a directory using rsync (with the --devices option). -func LocalCopy(source string, dest string, bwlimit string, xattrs bool) (string, error) { +func LocalCopy(source string, dest string, bwlimit string, xattrs bool, rsyncArgs ...string) (string, error) { err := os.MkdirAll(dest, 0755) if err != nil { return "", err @@ -52,10 +52,15 @@ func LocalCopy(source string, dest string, bwlimit string, xattrs bool) (string, args = append(args, "--bwlimit", bwlimit) } + if len(rsyncArgs) > 0 { + args = append(args, rsyncArgs...) + } + args = append(args, rsyncVerbosity, shared.AddSlash(source), dest) + msg, err := shared.RunCommand("rsync", args...) if err != nil { runError, ok := err.(shared.RunError) From 54c54b7603e3d8c66fe7e20adf98042c6dbada67 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Mon, 18 May 2020 13:22:02 +0100 Subject: [PATCH 2/2] lxd/storage/utils: Fixes ImageUnpack to not erase generated rootfs block file when doing rsync If the storage driver was either `dir` or `btrfs` then the generated rootfs block file was removed when unpacking unified tarballs. This was silently erroring because the storage driver then went ahead and created a blank rootfs block file, but the resulting VM wasn't bootable. Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lxd/storage/utils.go b/lxd/storage/utils.go index 587cc4b4c5..9ebcef3531 100644 --- a/lxd/storage/utils.go +++ b/lxd/storage/utils.go @@ -514,8 +514,9 @@ func ImageUnpack(imageFile, destPath, destBlockFile string, blockBackend, runnin return errors.Wrapf(err, "Failed to remove %q", imgPath) } - // Transfer the content. - _, err = rsync.LocalCopy(tempDir, destPath, "", true) + // Transfer the content excluding the destBlockFile name so that we don't delete the block file + // created above if the storage driver stores image files in the same directory as destPath. + _, err = rsync.LocalCopy(tempDir, destPath, "", true, "--exclude", filepath.Base(destBlockFile)) if err != nil { return err }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel