[lxc-devel] [lxd/master] Storage: Prevent modification of storage pool source property on non-pending members

tomponline on Github lxc-bot at linuxcontainers.org
Thu Dec 10 09:54:30 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201210/d91e8a8c/attachment.bin>
-------------- next part --------------
From e600777f0fa8f8a3ab4742da1490961e55d8f316 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 10 Dec 2020 09:53:01 +0000
Subject: [PATCH 1/3] lxd/db/storage/pools: Comment wrapping

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/db/storage_pools.go | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lxd/db/storage_pools.go b/lxd/db/storage_pools.go
index 378e6547c5..b38d7a62f7 100644
--- a/lxd/db/storage_pools.go
+++ b/lxd/db/storage_pools.go
@@ -946,8 +946,7 @@ func (c *Cluster) FillMissingStoragePoolDriver() error {
 	return err
 }
 
-// StoragePoolNodeConfigKeys lists all storage pool config keys which are
-// node-specific.
+// StoragePoolNodeConfigKeys lists all storage pool config keys which are node-specific.
 var StoragePoolNodeConfigKeys = []string{
 	"size",
 	"source",

From ecd88221bd7a55a4c6e8b1286714e4309744dbef Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 10 Dec 2020 09:53:15 +0000
Subject: [PATCH 2/3] lxd/storage/backend/lxd: Prevent modification of source
 field on non-pending nodes

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/storage/backend_lxd.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go
index 184c6e8d6a..048d6728bd 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -223,6 +223,12 @@ func (b *lxdBackend) Update(clientType request.ClientType, newDesc string, newCo
 	// Diff the configurations.
 	changedConfig, userOnly := b.detectChangedConfig(b.db.Config, newConfig)
 
+	// Check if the pool source is being changed that the local state is still pending, otherwise prevent it.
+	_, sourceChanged := changedConfig["source"]
+	if sourceChanged && b.LocalStatus() != api.StoragePoolStatusPending {
+		return fmt.Errorf("Pool source cannot be changed when not in pending state")
+	}
+
 	// Apply changes to local node if not pending and non-user config changed.
 	if len(changedConfig) != 0 && b.LocalStatus() != api.StoragePoolStatusPending && !userOnly {
 		err = b.driver.Update(changedConfig)

From 6404936c1516ebfc65614fd976ee2acaec2a4711 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Thu, 10 Dec 2020 09:53:35 +0000
Subject: [PATCH 3/3] lxd/storage/drivers/driver/lvm: Comment typo

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/storage/drivers/driver_lvm.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/storage/drivers/driver_lvm.go b/lxd/storage/drivers/driver_lvm.go
index 8654f0053d..a6f375a9dc 100644
--- a/lxd/storage/drivers/driver_lvm.go
+++ b/lxd/storage/drivers/driver_lvm.go
@@ -356,7 +356,7 @@ func (d *lvm) Delete(op *operations.Operation) error {
 				// Thin pool exists.
 				if err == nil {
 					// If thin pool is empty and the total VG volume count is 1 (our thin pool
-					// volume) then just remote the entire volume group.
+					// volume) then just remove the entire volume group.
 					if thinVolCount == 0 && lvCount == 1 {
 						removeVg = true
 					} else if thinVolCount == 0 && lvCount > 1 {


More information about the lxc-devel mailing list