From 5c82c31a6da0a3a312beb29d0d8a8b75965518bb Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Wed, 15 Jan 2025 15:29:12 +0100 Subject: [PATCH 1/3] fix: Fix PV grow_to_fill feature We need to set the `grow_to_fill` property on the LVMPV format not on the block device and the target size for the resize needs to be size of the PV, 'self._device' is the pool (VG) in this case. Related: https://github.com/storaged-project/blivet/issues/1320 Resolves: RHEL-73244 --- library/blivet.py | 4 ++-- tests/verify-pool-member-pvsize.yml | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/library/blivet.py b/library/blivet.py index efcf0b26..3a0e73ee 100644 --- a/library/blivet.py +++ b/library/blivet.py @@ -1853,8 +1853,8 @@ def _manage_members(self): pv.format.update_size_info() # set pv to be resizable if pv.format.resizable: - pv.grow_to_fill = True - ac = ActionResizeFormat(pv, self._device.size) + pv.format.grow_to_fill = True + ac = ActionResizeFormat(pv, pv.size) self._blivet.devicetree.actions.add(ac) else: log.warning("cannot grow/resize PV '%s', format is not resizable", pv.name) diff --git a/tests/verify-pool-member-pvsize.yml b/tests/verify-pool-member-pvsize.yml index d156e164..0685ad3c 100644 --- a/tests/verify-pool-member-pvsize.yml +++ b/tests/verify-pool-member-pvsize.yml @@ -4,21 +4,28 @@ register: actual_pv_size changed_when: false +- name: Get PE start for the PV + command: "pvs --noheadings --nosuffix --units b -o PESTART {{ st_pool_pv }}" + register: pv_pe_start + changed_when: false + - name: Convert blkinfo size to bytes bsize: size: "{{ storage_test_blkinfo.info[st_pool_pv]['size'] }}" register: dev_size +# the difference should be at maximum 1 PE + PE start - name: Verify each PV size assert: - that: (dev_size.bytes - actual_pv_size.stdout | int) | - abs / actual_pv_size.stdout | int < 0.04 + that: (dev_size.bytes - actual_pv_size.stdout | int) <= + (4194304 + pv_pe_start.stdout | int) msg: >- - PV resize failure; size difference too big + Unexpected difference between PV size and block device size: (device size: {{ dev_size.bytes }}) (actual PV size: {{ actual_pv_size.stdout }}) - name: Clean up test variables set_fact: actual_pv_size: null + pv_pe_start: null dev_size: null From 4182490f3a8b38a38591680239c82fe868946395 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Thu, 16 Jan 2025 11:06:45 +0100 Subject: [PATCH 2/3] tests: Test LV resize in the PV grow test as well We should check that LVs can be resized to 100 % of the (newly) available space in the VG after automatically growing the PVs. Related: RHEL-73244 --- tests/tests_lvm_pool_pv_grow.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tests/tests_lvm_pool_pv_grow.yml b/tests/tests_lvm_pool_pv_grow.yml index a039ec5f..a3aaa000 100644 --- a/tests/tests_lvm_pool_pv_grow.yml +++ b/tests/tests_lvm_pool_pv_grow.yml @@ -4,11 +4,7 @@ become: true vars: storage_safe_mode: false - mount_location1: '/opt/test1' - mount_location2: '/opt/test2' pv_size: '8g' - volume1_size: '2g' - volume2_size: '3g' tags: - tests::lvm @@ -57,11 +53,7 @@ state: present volumes: - name: test1 - size: "{{ volume1_size }}" - mount_point: "{{ mount_location1 }}" - - name: test2 - size: "{{ volume2_size }}" - mount_point: "{{ mount_location2 }}" + size: 100% - name: Verify role results include_tasks: verify-role-results.yml @@ -77,11 +69,7 @@ state: present volumes: - name: test1 - size: "{{ volume1_size }}" - mount_point: "{{ mount_location1 }}" - - name: test2 - size: "{{ volume2_size }}" - mount_point: "{{ mount_location2 }}" + size: 100% - name: Verify role results include_tasks: verify-role-results.yml @@ -96,7 +84,6 @@ state: "absent" volumes: - name: test1 - - name: test2 - name: Verify role results include_tasks: verify-role-results.yml From f085afd3023436565d7e23545d791ca50098d01c Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Fri, 17 Jan 2025 13:04:46 +0100 Subject: [PATCH 3/3] tests: Check return code instead of ouput for does_library_support There can be some noise in the output (like python deprecation warnings). --- tests/scripts/does_library_support.py | 3 ++- tests/test-verify-pool-members.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/scripts/does_library_support.py b/tests/scripts/does_library_support.py index 2044a87e..993b90b5 100755 --- a/tests/scripts/does_library_support.py +++ b/tests/scripts/does_library_support.py @@ -59,4 +59,5 @@ def is_supported(var): print("Usage: python %s " % sys.argv[0]) sys.exit(-1) - print(is_supported(sys.argv[1])) + ret = is_supported(sys.argv[1]) + sys.exit(0) if ret else sys.exit(1) diff --git a/tests/test-verify-pool-members.yml b/tests/test-verify-pool-members.yml index d56ebf45..757070ea 100644 --- a/tests/test-verify-pool-members.yml +++ b/tests/test-verify-pool-members.yml @@ -78,6 +78,7 @@ executable: "{{ ansible_python.executable }}" register: grow_supported changed_when: false + failed_when: grow_supported.rc not in [0, 1] - name: Verify that PVs fill the whole devices when they should include_tasks: verify-pool-member-pvsize.yml @@ -85,7 +86,7 @@ loop_control: loop_var: st_pool_pv when: - - grow_supported.stdout | trim == 'True' + - grow_supported.rc == 0 - storage_test_pool.type == "lvm" - storage_test_pool.grow_to_fill | bool