From f19a92064ac8acd5e7d141d83fe90cbef4402f46 Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Mon, 11 Jan 2021 14:46:32 +0000 Subject: [PATCH] LVM: Support only LVM 2.02.107+ Require LVM version 2.02.107 (circa 2014). Warn if the driver starts on a machine with an older LVM version. This is the first version that supports "lvs --readonly". Change-Id: Ibc49d870442a10605558c244ed97ce7671dc594e --- cinder/brick/local_dev/lvm.py | 9 +++++++++ .../tests/unit/volume/drivers/test_lvm_driver.py | 14 +++++++++++++- ...-minimum-version-2-02-107-df4551d088f8b5a3.yaml | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/lvm-minimum-version-2-02-107-df4551d088f8b5a3.yaml diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 6c6655d4e21..81153e5dfc4 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -33,6 +33,8 @@ from cinder import utils LOG = logging.getLogger(__name__) +MINIMUM_LVM_VERSION = (2, 2, 107) + class LVM(executor.Executor): """LVM object to enable various LVM related operations.""" @@ -93,6 +95,13 @@ class LVM(executor.Executor): _lvm_cmd_prefix.append('LVM_SUPPRESS_FD_WARNINGS=1') LVM.LVM_CMD_PREFIX = _lvm_cmd_prefix + lvm_version = LVM.get_lvm_version(root_helper) + if LVM.get_lvm_version(root_helper) < MINIMUM_LVM_VERSION: + LOG.warning("LVM version %(current)s is lower than the minimum " + "supported version: %(supported)s", + {'current': lvm_version, + 'supported': MINIMUM_LVM_VERSION}) + if create_vg and physical_volumes is not None: try: self._create_vg(physical_volumes) diff --git a/cinder/tests/unit/volume/drivers/test_lvm_driver.py b/cinder/tests/unit/volume/drivers/test_lvm_driver.py index 27f00fe064e..43c7f274b06 100644 --- a/cinder/tests/unit/volume/drivers/test_lvm_driver.py +++ b/cinder/tests/unit/volume/drivers/test_lvm_driver.py @@ -301,6 +301,9 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase): @mock.patch('cinder.brick.local_dev.lvm.LVM.supports_thin_provisioning', return_value=False) def test_lvm_type_auto_no_thin_support(self, *_unused_mocks): + self.mock_object(cinder.brick.local_dev.lvm.LVM, 'get_lvm_version', + return_value=(2, 2, 107)) + configuration = conf.Configuration(fake_opt, 'fake_group') configuration.lvm_type = 'auto' @@ -322,6 +325,9 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase): @mock.patch('cinder.brick.local_dev.lvm.LVM.supports_thin_provisioning', return_value=False) def test_lvm_type_auto_no_thin_pool(self, *_unused_mocks): + self.mock_object(cinder.brick.local_dev.lvm.LVM, 'get_lvm_version', + return_value=(2, 2, 107)) + configuration = conf.Configuration(fake_opt, 'fake_group') configuration.lvm_type = 'auto' @@ -421,7 +427,8 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase): def test_lvm_migrate_volume_volume_copy_error(self, vgs, copy_volume, mock_delete, mock_pvs, mock_create): - + self.mock_object(cinder.brick.local_dev.lvm.LVM, 'get_lvm_version', + return_value=(2, 2, 107)) hostname = socket.gethostname() capabilities = {'location_info': 'LVMVolumeDriver:%s:' 'cinder-volumes:default:0' % hostname} @@ -454,6 +461,8 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase): self.assertIsNone(model_update) def test_lvm_migrate_volume_proceed(self): + self.mock_object(cinder.brick.local_dev.lvm.LVM, 'get_lvm_version', + return_value=(2, 2, 107)) hostname = socket.gethostname() capabilities = {'location_info': 'LVMVolumeDriver:%s:' 'cinder-volumes-2:default:0' % hostname} @@ -498,6 +507,9 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase): sparse=False) def test_lvm_migrate_volume_proceed_with_thin(self): + self.mock_object(cinder.brick.local_dev.lvm.LVM, 'get_lvm_version', + return_value=(2, 2, 107)) + hostname = socket.gethostname() capabilities = {'location_info': 'LVMVolumeDriver:%s:' 'cinder-volumes-2:default:0' % hostname} diff --git a/releasenotes/notes/lvm-minimum-version-2-02-107-df4551d088f8b5a3.yaml b/releasenotes/notes/lvm-minimum-version-2-02-107-df4551d088f8b5a3.yaml new file mode 100644 index 00000000000..af3f7d2793a --- /dev/null +++ b/releasenotes/notes/lvm-minimum-version-2-02-107-df4551d088f8b5a3.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - | + Cinder now requires LVM version 2.02.107 or newer.