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

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) ===
For LVM and ZFS.
From 1dc036c4e5f798d7284f1425355f67941b8b6f2b Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Wed, 29 Apr 2020 15:58:21 +0100
Subject: [PATCH 1/2] lxd/storage/drivers/driver/lvm/volumes:
 CreateVolumeFromCopy only set volume size from expanded config when source is
 image

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/storage/drivers/driver_lvm_utils.go | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lxd/storage/drivers/driver_lvm_utils.go 
b/lxd/storage/drivers/driver_lvm_utils.go
index 22ddb710be..37f914be05 100644
--- a/lxd/storage/drivers/driver_lvm_utils.go
+++ b/lxd/storage/drivers/driver_lvm_utils.go
@@ -650,8 +650,16 @@ func (d *lvm) copyThinpoolVolume(vol, srcVol Volume, 
srcSnapshots []Volume, refr
                }
        }
 
-       // Resize the new volume and filesystem to the correct size.
-       err = d.SetVolumeQuota(vol, d.volumeSize(vol), nil)
+       // Default to non-expanded config, so we only use user specified volume 
size.
+       // This is so the pool default volume size isn't take into account for 
volume copies.
+       volSize := vol.config["size"]
+
+       // If source is an image then use expanded config so that we take into 
account pool default volume size.
+       if srcVol.volType == VolumeTypeImage {
+               volSize = vol.ExpandedConfig("size")
+       }
+
+       err = d.SetVolumeQuota(vol, volSize, nil)
        if err != nil {
                return err
        }

From 55cb5404090b78b90cf50ce0a243a36312e09389 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Wed, 29 Apr 2020 15:37:39 +0100
Subject: [PATCH 2/2] lxd/storage/drivers/driver/zfs/volumes:
 CreateVolumeFromCopy only set volume size from expanded config when source is
 image

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/storage/drivers/driver_zfs_volumes.go | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lxd/storage/drivers/driver_zfs_volumes.go 
b/lxd/storage/drivers/driver_zfs_volumes.go
index 972c63211e..db87f9e4d1 100644
--- a/lxd/storage/drivers/driver_zfs_volumes.go
+++ b/lxd/storage/drivers/driver_zfs_volumes.go
@@ -594,15 +594,22 @@ func (d *zfs) CreateVolumeFromCopy(vol Volume, srcVol 
Volume, copySnapshots bool
                }
        }
 
-       // Resize the new volume and filesystem to the correct size.
-       err := d.SetVolumeQuota(vol, vol.ExpandedConfig("size"), nil)
+       // Default to non-expanded config, so we only use user specified volume 
size.
+       // This is so the pool default volume size isn't take into account for 
volume copies.
+       volSize := vol.config["size"]
+
+       // If source is an image then use expanded config so that we take into 
account pool default volume size.
+       if srcVol.volType == VolumeTypeImage {
+               volSize = vol.ExpandedConfig("size")
+       }
+
+       err := d.SetVolumeQuota(vol, volSize, op)
        if err != nil {
                return err
        }
 
        // All done.
        revert.Success()
-
        return nil
 }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to