[lxc-devel] [lxd/master] Storage: Allow LVM pool to be backed by existing non-empty volume group
tomponline on Github
lxc-bot at linuxcontainers.org
Wed Feb 19 13:44:30 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 751 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200219/cc8183a7/attachment.bin>
-------------- next part --------------
From fb647be551394e3b057161049826e1d98aab99b7 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 19 Feb 2020 13:29:45 +0000
Subject: [PATCH 1/4] lxd/storage/drivers/driver/lvm: Adds lvm.vg.force_reuse
config option
Allows creating a new storage pool backend by an existing non-empty volume group.
This is for when you using a VG that is mixed with other uses.
Note: This is a potentially dangerous option as it may cause volume name conflicts.
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/drivers/driver_lvm.go | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/lxd/storage/drivers/driver_lvm.go b/lxd/storage/drivers/driver_lvm.go
index 0576408b90..f75d217f83 100644
--- a/lxd/storage/drivers/driver_lvm.go
+++ b/lxd/storage/drivers/driver_lvm.go
@@ -246,13 +246,20 @@ func (d *lvm) Create() error {
empty = true
}
- if !empty {
- return fmt.Errorf("Volume group %q is not empty", d.config["lvm.vg_name"])
- }
+ // Skip the in use checks if the force reuse option is enabled. This allows a storage pool to be
+ // backed by an existing non-empty volume group. Note: This option should be used with care, as LXD
+ // can then not guarantee that volume name conflicts won't occur with non-LXD created volumes in
+ // the same volume group. This could also potentially lead to LXD deleting a non-LXD volume should
+ // name conflicts occur.
+ if !shared.IsTrue(d.config["lvm.vg.force_reuse"]) {
+ if !empty {
+ return fmt.Errorf("Volume group %q is not empty", d.config["lvm.vg_name"])
+ }
- // Check the tags on the volume group to check it is not already being used by LXD.
- if shared.StringInSlice(lvmVgPoolMarker, vgTags) {
- return fmt.Errorf("Volume group %q is already used by LXD", d.config["lvm.vg_name"])
+ // Check the tags on the volume group to check it is not already being used by LXD.
+ if shared.StringInSlice(lvmVgPoolMarker, vgTags) {
+ return fmt.Errorf("Volume group %q is already used by LXD", d.config["lvm.vg_name"])
+ }
}
} else {
// Create physical volume if doesn't exist.
@@ -430,6 +437,7 @@ func (d *lvm) Validate(config map[string]string) error {
},
"volume.lvm.stripes": shared.IsUint32,
"volume.lvm.stripes.size": shared.IsSize,
+ "lvm.vg.force_reuse": shared.IsBool,
}
err := d.validatePool(config, rules)
From f07d2459bd4ba43b6252d183a95f6850e30ea7ef Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 19 Feb 2020 13:31:26 +0000
Subject: [PATCH 2/4] lxd/storage/pools/config: Adds lvm.vg.force_reuse option
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage_pools_config.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/lxd/storage_pools_config.go b/lxd/storage_pools_config.go
index 43e9ab225c..e5b04e742d 100644
--- a/lxd/storage_pools_config.go
+++ b/lxd/storage_pools_config.go
@@ -81,6 +81,7 @@ var storagePoolConfigKeys = map[string]func(value string) error{
"lvm.vg_name": shared.IsAny,
"volume.lvm.stripes": shared.IsUint32,
"volume.lvm.stripes.size": shared.IsSize,
+ "lvm.vg.force_reuse": shared.IsBool,
// valid drivers: btrfs, lvm, zfs
"size": shared.IsSize,
From 6d3751d0efa35fd5e3d37958333bd61652af6b9d Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 19 Feb 2020 13:39:33 +0000
Subject: [PATCH 3/4] doc/api: Adds API extension storage_lvm_vg_force_reuse
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
doc/api-extensions.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/doc/api-extensions.md b/doc/api-extensions.md
index b0e5838c41..df2a62f160 100644
--- a/doc/api-extensions.md
+++ b/doc/api-extensions.md
@@ -920,3 +920,9 @@ to specify to the ideal number of database voter and standbys.
## firewall\_driver
Adds the `Firewall` property to the ServerEnvironment struct indicating the firewall driver being used.
+
+## storage\_lvm\_vg\_force\_reuse
+Introduces the ability to create a storage pool from an existing non-empty volume group.
+This option should be used with care, as LXD can then not guarantee that volume name conflicts won't occur
+with non-LXD created volumes in the same volume group.
+This could also potentially lead to LXD deleting a non-LXD volume should name conflicts occur.
From abd4db635a5d03ad9ab466fafcd627397cfce23e Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 19 Feb 2020 13:40:24 +0000
Subject: [PATCH 4/4] doc/storage: Adds lvm.vg.force_reuse option to storage
pool config
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
doc/storage.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/doc/storage.md b/doc/storage.md
index f4164efd25..86aa2a4441 100644
--- a/doc/storage.md
+++ b/doc/storage.md
@@ -23,6 +23,7 @@ cephfs.user.name | string | cephfs driver
lvm.thinpool\_name | string | lvm driver | LXDThinPool | storage | Thin pool where volumes are created.
lvm.use\_thinpool | bool | lvm driver | true | storage\_lvm\_use\_thinpool | Whether the storage pool uses a thinpool for logical volumes.
lvm.vg\_name | string | lvm driver | name of the pool | storage | Name of the volume group to create.
+lvm.vg.force\_reuse | bool | lvm driver | false | storage\_lvm\_vg\_force\_reuse | Force using an existing non-empty volume group.
volume.lvm.stripes | string | lvm driver | - | storage\_lvm\_stripes | Number of stripes to use for new volumes (or thin pool volume).
volume.lvm.stripes.size | string | lvm driver | - | storage\_lvm\_stripes | Size of stripes to use (at least 4096 bytes and multiple of 512bytes).
rsync.bwlimit | string | - | 0 (no limit) | storage\_rsync\_bwlimit | Specifies the upper limit to be placed on the socket I/O whenever rsync has to be used to transfer storage entities.
More information about the lxc-devel
mailing list