diff --git a/diskimage_builder/elements/growvols/static/usr/local/sbin/growvols b/diskimage_builder/elements/growvols/static/usr/local/sbin/growvols index 8894bed4..e677d8c8 100755 --- a/diskimage_builder/elements/growvols/static/usr/local/sbin/growvols +++ b/diskimage_builder/elements/growvols/static/usr/local/sbin/growvols @@ -475,7 +475,7 @@ def find_thin_pool(devices, group): break if not thin_pool_device: - return + return None, None # ensure every volume uses the pool for d in lvs_devices: @@ -490,7 +490,7 @@ def find_thin_pool(devices, group): raise Exception('All volumes need to be in pool %s. ' '%s is in pool %s' % (thin_pool_name, lv_name, pool_lv)) - return thin_pool_device + return thin_pool_device, thin_pool_name def main(argv): @@ -522,13 +522,16 @@ def main(argv): group = find_group(opts) partnum = find_next_partnum(devices, disk_name) devname = find_next_device_name(devices, disk_name, partnum) - thin_pool = find_thin_pool(devices, group) + thin_pool, thin_pool_name = find_thin_pool(devices, group) if thin_pool: - # total size available, reduced by POOL_METADATA_SIZE - # rounded down to whole extent and reduced by 1 extent - # for metadata overhead + # reserve for the size of the metadata volume size_bytes -= POOL_METADATA_SIZE + # reserve for the size of the spare metadata volume, + # used for metadata check and repair + size_bytes -= POOL_METADATA_SIZE + # round down to a whole extent size_bytes -= size_bytes % PHYSICAL_EXTENT_BYTES + # reduce for metadata overhead size_bytes -= PHYSICAL_EXTENT_BYTES dev_path = '/dev/%s' % devname grow_vols = find_grow_vols(opts, devices, group, size_bytes) @@ -562,8 +565,7 @@ def main(argv): 'lvextend', '--poolmetadatasize', '+%sB' % POOL_METADATA_SIZE, - thin_pool, - dev_path + '%s/%s' % (group, thin_pool_name) ], 'Add %s to thin pool metadata %s' % ( convert_bytes(POOL_METADATA_SIZE), thin_pool))) commands.append(Command([ diff --git a/diskimage_builder/elements/growvols/tests/test_growvols.py b/diskimage_builder/elements/growvols/tests/test_growvols.py index e45c652a..5817b6de 100644 --- a/diskimage_builder/elements/growvols/tests/test_growvols.py +++ b/diskimage_builder/elements/growvols/tests/test_growvols.py @@ -433,14 +433,14 @@ class TestGrowvols(base.BaseTestCase): def test_find_thin_pool(self, mock_execute): # No thin pool mock_execute.return_value = LVS - self.assertIsNone(growvols.find_thin_pool(DEVICES, 'vg')) + self.assertEqual((None, None), growvols.find_thin_pool(DEVICES, 'vg')) mock_execute.assert_called_once_with([ 'lvs', '--noheadings', '--options', 'lv_name,lv_dm_path,lv_attr,pool_lv']) # One thin pool, all volumes use it mock_execute.return_value = LVS_THIN - self.assertEqual('/dev/mapper/vg-lv_thinpool', + self.assertEqual(('/dev/mapper/vg-lv_thinpool', 'lv_thinpool'), growvols.find_thin_pool(DEVICES, 'vg')) # One pool, not used by all volumes @@ -621,14 +621,14 @@ class TestGrowvols(base.BaseTestCase): mock.call(['pvcreate', '/dev/sda5']), mock.call(['vgextend', 'vg', '/dev/sda5']), mock.call(['lvextend', '--poolmetadatasize', '+1073741824B', + 'vg/lv_thinpool']), + mock.call(['lvextend', '-L+207253143552B', '/dev/mapper/vg-lv_thinpool', '/dev/sda5']), - mock.call(['lvextend', '-L+208326885376B', - '/dev/mapper/vg-lv_thinpool', '/dev/sda5']), - mock.call(['lvextend', '--size', '+41662021632B', + mock.call(['lvextend', '--size', '+41448112128B', '/dev/mapper/vg-lv_home']), - mock.call(['lvextend', '--size', '+83328237568B', + mock.call(['lvextend', '--size', '+82900418560B', '/dev/mapper/vg-lv_var']), - mock.call(['lvextend', '--size', '+83336626176B', + mock.call(['lvextend', '--size', '+82904612864B', '/dev/mapper/vg-lv_root']), mock.call(['xfs_growfs', '/dev/mapper/vg-lv_home']), mock.call(['xfs_growfs', '/dev/mapper/vg-lv_var']),