The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7086
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) ===
From ff48c17f1c6847eadcf0a7266fda3a86959e4a56 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Thu, 26 Mar 2020 16:50:56 +0000 Subject: [PATCH 1/3] lxd/storage/drivers: Adds OptimizedBackups driver Info flag Used to indicate if the driver supports optimized backups. Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/drivers/driver_btrfs.go | 1 + lxd/storage/drivers/driver_types.go | 1 + lxd/storage/drivers/driver_zfs.go | 1 + 3 files changed, 3 insertions(+) diff --git a/lxd/storage/drivers/driver_btrfs.go b/lxd/storage/drivers/driver_btrfs.go index db24763645..4c4e569b81 100644 --- a/lxd/storage/drivers/driver_btrfs.go +++ b/lxd/storage/drivers/driver_btrfs.go @@ -72,6 +72,7 @@ func (d *btrfs) Info() Info { Name: "btrfs", Version: btrfsVersion, OptimizedImages: true, + OptimizedBackups: true, PreservesInodes: !d.state.OS.RunningInUserNS, Remote: false, VolumeTypes: []VolumeType{VolumeTypeCustom, VolumeTypeImage, VolumeTypeContainer, VolumeTypeVM}, diff --git a/lxd/storage/drivers/driver_types.go b/lxd/storage/drivers/driver_types.go index ea6dfaabbd..c7547211ed 100644 --- a/lxd/storage/drivers/driver_types.go +++ b/lxd/storage/drivers/driver_types.go @@ -7,6 +7,7 @@ type Info struct { VolumeTypes []VolumeType // Supported volume types. Remote bool // Whether the driver uses a remote backing store. OptimizedImages bool // Whether driver stores images as separate volume. + OptimizedBackups bool // Whether driver supports optimized volume backups. PreservesInodes bool // Whether driver preserves inodes when volumes are moved hosts. BlockBacking bool // Whether driver uses block devices as backing store. RunningQuotaResize bool // Whether quota resize is supported whilst instance running. diff --git a/lxd/storage/drivers/driver_zfs.go b/lxd/storage/drivers/driver_zfs.go index d7b2a7b113..4cb9c824d0 100644 --- a/lxd/storage/drivers/driver_zfs.go +++ b/lxd/storage/drivers/driver_zfs.go @@ -102,6 +102,7 @@ func (d *zfs) Info() Info { Name: "zfs", Version: zfsVersion, OptimizedImages: true, + OptimizedBackups: true, PreservesInodes: true, Remote: false, VolumeTypes: []VolumeType{VolumeTypeCustom, VolumeTypeImage, VolumeTypeContainer, VolumeTypeVM}, From e4824a364e4663069df6760dfec6fee36ce8a140 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Thu, 26 Mar 2020 16:51:33 +0000 Subject: [PATCH 2/3] lxd/backup: Ignore requests for optimized backups when pool driver doesn't support it This ensures that the index.yaml file doesn't indicate an optimized backup that would prevent importing it again. Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/backup.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lxd/backup.go b/lxd/backup.go index dda729d263..1db85bcb57 100644 --- a/lxd/backup.go +++ b/lxd/backup.go @@ -47,6 +47,11 @@ func backupCreate(s *state.State, args db.InstanceBackupArgs, sourceInst instanc return errors.Wrap(err, "Load instance storage pool") } + // Ignore requests for optimized backups when pool driver doesn't support it. + if args.OptimizedStorage && !pool.Driver().Info().OptimizedBackups { + args.OptimizedStorage = false + } + // Create the database entry. err = s.Cluster.InstanceBackupCreate(args) if err != nil { From a404c1560d4664e71c93479c5d7465ec44e349c2 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Thu, 26 Mar 2020 16:52:17 +0000 Subject: [PATCH 3/3] lxd/instances/post: Ensure optimized backup imports only import into same storage driver pools Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/instances_post.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lxd/instances_post.go b/lxd/instances_post.go index 768a82d4a0..f3273829af 100644 --- a/lxd/instances_post.go +++ b/lxd/instances_post.go @@ -649,6 +649,11 @@ func createFromBackup(d *Daemon, project string, data io.Reader, pool string) re return err } + // Check if the backup is optimized that the source pool driver matches the target pool driver. + if *bInfo.OptimizedStorage && pool.Driver().Name() != bInfo.Backend { + return fmt.Errorf("Optimized backup storage driver differs from the target storage pool driver") + } + // Dump tarball to storage. Because the backup file is unpacked and restored onto the storage // device before the instance is created in the database it is necessary to return two functions; // a post hook that can be run once the instance has been created in the database to run any
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel