Cluster volume group fix in lvm
After adding lvm cluster volume group on host with cinder-volume service, this service failed to start. Add --ignoreskippedcluster option to pvs and unit test for pvs command in case cluster volume group exist. Closes-Bug: 1640536 Change-Id: I89ffea86d0951fe4c80783a612b6cde76c8838b4
This commit is contained in:
parent
67c4c96a6a
commit
51815402f0
@ -71,6 +71,7 @@ class LVM(executor.Executor):
|
|||||||
self.vg_thin_pool_free_space = 0.0
|
self.vg_thin_pool_free_space = 0.0
|
||||||
self._supports_snapshot_lv_activation = None
|
self._supports_snapshot_lv_activation = None
|
||||||
self._supports_lvchange_ignoreskipactivation = None
|
self._supports_lvchange_ignoreskipactivation = None
|
||||||
|
self._supports_pvs_ignoreskippedcluster = None
|
||||||
self.vg_provisioned_capacity = 0.0
|
self.vg_provisioned_capacity = 0.0
|
||||||
|
|
||||||
# Ensure LVM_SYSTEM_DIR has been added to LVM.LVM_CMD_PREFIX
|
# Ensure LVM_SYSTEM_DIR has been added to LVM.LVM_CMD_PREFIX
|
||||||
@ -257,6 +258,22 @@ class LVM(executor.Executor):
|
|||||||
|
|
||||||
return self._supports_lvchange_ignoreskipactivation
|
return self._supports_lvchange_ignoreskipactivation
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supports_pvs_ignoreskippedcluster(self):
|
||||||
|
"""Property indicating whether pvs supports --ignoreskippedcluster
|
||||||
|
|
||||||
|
Check for LVM version >= 2.02.103.
|
||||||
|
(LVM2 git: baf95bbff cmdline: Add --ignoreskippedcluster.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if self._supports_pvs_ignoreskippedcluster is not None:
|
||||||
|
return self._supports_pvs_ignoreskippedcluster
|
||||||
|
|
||||||
|
self._supports_pvs_ignoreskippedcluster = (
|
||||||
|
self.get_lvm_version(self._root_helper) >= (2, 2, 103))
|
||||||
|
|
||||||
|
return self._supports_pvs_ignoreskippedcluster
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_lv_info(root_helper, vg_name=None, lv_name=None):
|
def get_lv_info(root_helper, vg_name=None, lv_name=None):
|
||||||
"""Retrieve info about LVs (all, in a VG, or a single LV).
|
"""Retrieve info about LVs (all, in a VG, or a single LV).
|
||||||
@ -334,6 +351,9 @@ class LVM(executor.Executor):
|
|||||||
'-o', 'vg_name,name,size,free',
|
'-o', 'vg_name,name,size,free',
|
||||||
'--separator', field_sep,
|
'--separator', field_sep,
|
||||||
'--nosuffix']
|
'--nosuffix']
|
||||||
|
if LVM.supports_pvs_ignoreskippedcluster:
|
||||||
|
cmd.append('--ignoreskippedcluster')
|
||||||
|
|
||||||
(out, _err) = putils.execute(*cmd,
|
(out, _err) = putils.execute(*cmd,
|
||||||
root_helper=root_helper,
|
root_helper=root_helper,
|
||||||
run_as_root=True)
|
run_as_root=True)
|
||||||
|
@ -140,6 +140,12 @@ class BrickLvmTestCase(test.TestCase):
|
|||||||
data += " fake-vg|/dev/sdb|10.00|1.00\n"
|
data += " fake-vg|/dev/sdb|10.00|1.00\n"
|
||||||
data += " fake-vg|/dev/sdc|10.00|8.99\n"
|
data += " fake-vg|/dev/sdc|10.00|8.99\n"
|
||||||
data += " fake-vg-2|/dev/sdd|10.00|9.99\n"
|
data += " fake-vg-2|/dev/sdd|10.00|9.99\n"
|
||||||
|
if '--ignoreskippedcluster' not in cmd_string:
|
||||||
|
raise processutils.ProcessExecutionError(
|
||||||
|
stderr="Skipping clustered volume group",
|
||||||
|
stdout=data,
|
||||||
|
exit_code=5
|
||||||
|
)
|
||||||
elif _lvm_prefix + 'lvs, --noheadings, --unit=g' \
|
elif _lvm_prefix + 'lvs, --noheadings, --unit=g' \
|
||||||
', -o, size,data_percent, --separator, :' in cmd_string:
|
', -o, size,data_percent, --separator, :' in cmd_string:
|
||||||
if 'test-prov-cap-pool' in cmd_string:
|
if 'test-prov-cap-pool' in cmd_string:
|
||||||
@ -280,6 +286,21 @@ class BrickLvmTestCase(test.TestCase):
|
|||||||
|
|
||||||
self.vg._supports_lvchange_ignoreskipactivation = None
|
self.vg._supports_lvchange_ignoreskipactivation = None
|
||||||
|
|
||||||
|
def test_pvs_ignoreskippedcluster_support(self):
|
||||||
|
"""Tests if lvm support ignoreskippedcluster option."""
|
||||||
|
|
||||||
|
self.vg._supports_pvs_ignoreskippedcluster = None
|
||||||
|
with mock.patch.object(processutils, 'execute',
|
||||||
|
self.fake_pretend_lvm_version):
|
||||||
|
self.assertTrue(self.vg.supports_pvs_ignoreskippedcluster)
|
||||||
|
|
||||||
|
self.vg._supports_pvs_ignoreskippedcluster = None
|
||||||
|
with mock.patch.object(processutils, 'execute',
|
||||||
|
self.fake_old_lvm_version):
|
||||||
|
self.assertFalse(self.vg.supports_pvs_ignoreskippedcluster)
|
||||||
|
|
||||||
|
self.vg._supports_pvs_ignoreskippedcluster = None
|
||||||
|
|
||||||
def test_thin_pool_creation(self):
|
def test_thin_pool_creation(self):
|
||||||
|
|
||||||
# The size of fake-vg volume group is 10g, so the calculated thin
|
# The size of fake-vg volume group is 10g, so the calculated thin
|
||||||
|
Loading…
Reference in New Issue
Block a user