The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6899
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) === A bug that was fixed in 3.19 that allowed existing non-empty volume groups to be used for new storage pools has caused issues with some users depending on that behaviour. This PR introduces the `lvm.vg.force_reuse` pool config option to allow an existing non-empty volume group to be used for new storage pools. Related discussion: https://discuss.linuxcontainers.org/t/error-when-trying-to-use-an-existing-lvm-pool-with-a-new-installation/6809
From fb647be551394e3b057161049826e1d98aab99b7 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@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.parr...@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.parr...@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.parr...@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.parr...@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.parr...@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.parr...@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.parr...@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.
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel