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

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 4d761a8904277780fe8dd31d6f3bd3216bb181b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Fri, 20 Dec 2019 10:03:41 -0500
Subject: [PATCH 1/3] lxd/storage/drivers: Rename applyQuota to initVolume
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/storage/drivers/generic.go | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/lxd/storage/drivers/generic.go b/lxd/storage/drivers/generic.go
index 80acfd2cb7..b0a1855444 100644
--- a/lxd/storage/drivers/generic.go
+++ b/lxd/storage/drivers/generic.go
@@ -15,7 +15,8 @@ import (
 )
 
 // genericCopyVolume copies a volume and its snapshots using a non-optimized 
method.
-func genericCopyVolume(d Driver, applyQuota func(vol Volume) (func(), error), 
vol Volume, srcVol Volume, srcSnapshots []Volume, op *operations.Operation) 
error {
+// initVolume is run against the main volume (not the snapshots) and is often 
used for quota initialization.
+func genericCopyVolume(d Driver, initVolume func(vol Volume) (func(), error), 
vol Volume, srcVol Volume, srcSnapshots []Volume, op *operations.Operation) 
error {
        if vol.contentType != ContentTypeFS || srcVol.contentType != 
ContentTypeFS {
                return fmt.Errorf("Content type not supported")
        }
@@ -74,9 +75,9 @@ func genericCopyVolume(d Driver, applyQuota func(vol Volume) 
(func(), error), vo
                        }
                }
 
-               // Apply some quotas if needed.
-               if applyQuota != nil {
-                       _, err := applyQuota(vol)
+               // Run volume-specific init logic.
+               if initVolume != nil {
+                       _, err := initVolume(vol)
                        if err != nil {
                                return err
                        }
@@ -97,7 +98,8 @@ func genericCopyVolume(d Driver, applyQuota func(vol Volume) 
(func(), error), vo
 }
 
 // genericCreateVolumeFromMigration receives a volume and its snapshots over a 
non-optimized method.
-func genericCreateVolumeFromMigration(d Driver, applyQuota func(vol Volume) 
(func(), error), vol Volume, conn io.ReadWriteCloser, volTargetArgs 
migration.VolumeTargetArgs, preFiller *VolumeFiller, op *operations.Operation) 
error {
+// initVolume is run against the main volume (not the snapshots) and is often 
used for quota initialization.
+func genericCreateVolumeFromMigration(d Driver, initVolume func(vol Volume) 
(func(), error), vol Volume, conn io.ReadWriteCloser, volTargetArgs 
migration.VolumeTargetArgs, preFiller *VolumeFiller, op *operations.Operation) 
error {
        // Create the main volume path.
        if !volTargetArgs.Refresh {
                err := d.CreateVolume(vol, preFiller, op)
@@ -154,9 +156,9 @@ func genericCreateVolumeFromMigration(d Driver, applyQuota 
func(vol Volume) (fun
                        revertSnaps = append(revertSnaps, snapName)
                }
 
-               // Apply quotas.
-               if applyQuota != nil {
-                       _, err := applyQuota(vol)
+               // Run volume-specific init logic.
+               if initVolume != nil {
+                       _, err := initVolume(vol)
                        if err != nil {
                                return err
                        }

From 2e688133db004c4560acf0df6874f04fc8915468 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Fri, 3 Jan 2020 14:21:21 -0500
Subject: [PATCH 2/3] lxd/storage/drivers: Fix bad ExpandedConfig
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/storage/drivers/volume.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/storage/drivers/volume.go b/lxd/storage/drivers/volume.go
index 055b233040..b7ec773dff 100644
--- a/lxd/storage/drivers/volume.go
+++ b/lxd/storage/drivers/volume.go
@@ -83,7 +83,7 @@ func (v Volume) Config() map[string]string {
 // ExpandedConfig returns either the value of the volume's config key or the 
pool's config "volume.{key}" value.
 func (v Volume) ExpandedConfig(key string) string {
        volVal, ok := v.config[key]
-       if !ok {
+       if ok {
                return volVal
        }
 

From 6a74935ad10fe0a4c68f9246a5de6072216228df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Fri, 3 Jan 2020 14:24:45 -0500
Subject: [PATCH 3/3] lxd/storage: Include size in instance update
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/storage/backend_lxd.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go
index e8eb4ee115..726f69366c 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -1231,7 +1231,13 @@ func (b *lxdBackend) UpdateInstance(inst 
instance.Instance, newDesc string, newC
                        return fmt.Errorf("Instance volume 'block.filesystem' 
property cannot be changed")
                }
 
-               curVol := b.newVolume(volType, contentType, volStorageName, 
curVol.Config)
+               // Get the root disk device config.
+               rootDiskConf, err := b.instanceRootVolumeConfig(inst)
+               if err != nil {
+                       return err
+               }
+
+               curVol := b.newVolume(volType, contentType, volStorageName, 
rootDiskConf)
                if !userOnly {
                        err = b.driver.UpdateVolume(curVol, changedConfig)
                        if err != nil {
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to