[lxc-devel] [lxd/master] lxd/storage: Add LocalStructure to Info

monstermunchkin on Github lxc-bot at linuxcontainers.org
Wed Feb 5 15:27:35 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 324 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200205/837b0a03/attachment.bin>
-------------- next part --------------
From 094fcecc76dd5226d2db0eb4b9fe48652e439386 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Wed, 5 Feb 2020 15:55:02 +0100
Subject: [PATCH 1/2] lxd/storage/drivers: Add LocalStructure to Info

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 lxd/storage/drivers/driver_types.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lxd/storage/drivers/driver_types.go b/lxd/storage/drivers/driver_types.go
index dab2aa5694..399fcb13e1 100644
--- a/lxd/storage/drivers/driver_types.go
+++ b/lxd/storage/drivers/driver_types.go
@@ -12,6 +12,7 @@ type Info struct {
 	RunningQuotaResize    bool         // Whether quota resize is supported whilst instance running.
 	RunningSnapshotFreeze bool         // Whether instance should be frozen during snapshot if running.
 	DirectIO              bool         // Whether the driver supports direct I/O.
+	LocalStructure        bool         // Whether the directory structure needs to be created.
 }
 
 // VolumeFiller provides a struct for filling a volume.

From 2d5fe3b17efe1b9759f6fff618318d3eea5191ad Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.hipp at canonical.com>
Date: Wed, 5 Feb 2020 15:57:01 +0100
Subject: [PATCH 2/2] lxd/storage: Honor LocalStructure in pool actions

This honors the LocalStructure information when creating and deleting
storage pools.

Signed-off-by: Thomas Hipp <thomas.hipp at canonical.com>
---
 lxd/storage/backend_lxd.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go
index 393ef62fd7..e9052bb38f 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -81,6 +81,14 @@ func (b *lxdBackend) create(localOnly bool, op *operations.Operation) error {
 
 	// If dealing with a remote storage pool, we're done now.
 	if b.driver.Info().Remote && localOnly {
+		if b.driver.Info().LocalStructure {
+			// Create the directory structure.
+			err = b.createStorageStructure(path)
+			if err != nil {
+				return err
+			}
+		}
+
 		revert.Success()
 		return nil
 	}
@@ -199,7 +207,7 @@ func (b *lxdBackend) Delete(localOnly bool, op *operations.Operation) error {
 	}
 
 	// Delete the low-level storage.
-	if !localOnly || !b.driver.Info().Remote {
+	if !localOnly || !b.driver.Info().Remote || b.driver.Info().LocalStructure {
 		err := b.driver.Delete(op)
 		if err != nil {
 			return err


More information about the lxc-devel mailing list