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
This commit is contained in:
Eric Harney 2021-01-11 14:46:32 +00:00
parent 662bb58517
commit f19a92064a
3 changed files with 26 additions and 1 deletions

View File

@ -33,6 +33,8 @@ from cinder import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
MINIMUM_LVM_VERSION = (2, 2, 107)
class LVM(executor.Executor): class LVM(executor.Executor):
"""LVM object to enable various LVM related operations.""" """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_cmd_prefix.append('LVM_SUPPRESS_FD_WARNINGS=1')
LVM.LVM_CMD_PREFIX = _lvm_cmd_prefix 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: if create_vg and physical_volumes is not None:
try: try:
self._create_vg(physical_volumes) self._create_vg(physical_volumes)

View File

@ -301,6 +301,9 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase):
@mock.patch('cinder.brick.local_dev.lvm.LVM.supports_thin_provisioning', @mock.patch('cinder.brick.local_dev.lvm.LVM.supports_thin_provisioning',
return_value=False) return_value=False)
def test_lvm_type_auto_no_thin_support(self, *_unused_mocks): 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 = conf.Configuration(fake_opt, 'fake_group')
configuration.lvm_type = 'auto' configuration.lvm_type = 'auto'
@ -322,6 +325,9 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase):
@mock.patch('cinder.brick.local_dev.lvm.LVM.supports_thin_provisioning', @mock.patch('cinder.brick.local_dev.lvm.LVM.supports_thin_provisioning',
return_value=False) return_value=False)
def test_lvm_type_auto_no_thin_pool(self, *_unused_mocks): 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 = conf.Configuration(fake_opt, 'fake_group')
configuration.lvm_type = 'auto' 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, def test_lvm_migrate_volume_volume_copy_error(self, vgs, copy_volume,
mock_delete, mock_pvs, mock_delete, mock_pvs,
mock_create): mock_create):
self.mock_object(cinder.brick.local_dev.lvm.LVM, 'get_lvm_version',
return_value=(2, 2, 107))
hostname = socket.gethostname() hostname = socket.gethostname()
capabilities = {'location_info': 'LVMVolumeDriver:%s:' capabilities = {'location_info': 'LVMVolumeDriver:%s:'
'cinder-volumes:default:0' % hostname} 'cinder-volumes:default:0' % hostname}
@ -454,6 +461,8 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase):
self.assertIsNone(model_update) self.assertIsNone(model_update)
def test_lvm_migrate_volume_proceed(self): 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() hostname = socket.gethostname()
capabilities = {'location_info': 'LVMVolumeDriver:%s:' capabilities = {'location_info': 'LVMVolumeDriver:%s:'
'cinder-volumes-2:default:0' % hostname} 'cinder-volumes-2:default:0' % hostname}
@ -498,6 +507,9 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase):
sparse=False) sparse=False)
def test_lvm_migrate_volume_proceed_with_thin(self): 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() hostname = socket.gethostname()
capabilities = {'location_info': 'LVMVolumeDriver:%s:' capabilities = {'location_info': 'LVMVolumeDriver:%s:'
'cinder-volumes-2:default:0' % hostname} 'cinder-volumes-2:default:0' % hostname}

View File

@ -0,0 +1,4 @@
---
upgrade:
- |
Cinder now requires LVM version 2.02.107 or newer.