From 98136f0ef5d0e76760619b7452ad4e5ab26fca63 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Mon, 12 May 2025 15:46:34 +0200 Subject: [PATCH] fix: Show error when trying to put LVM volume on partition pool Trying this currently fails later with an exception so this just makes sure we show a nicer error message describing the error in the provided playbook. Resolves: RHEL-71246 --- library/blivet.py | 3 +++ tests/tests_lvm_errors.yml | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/library/blivet.py b/library/blivet.py index 67122ea78..c94a8c71b 100644 --- a/library/blivet.py +++ b/library/blivet.py @@ -1175,6 +1175,9 @@ def _create(self): if self._device: return + if self._blivet_pool._device and self._blivet_pool._device.type != "lvmvg": + raise BlivetAnsibleError("LVM volume can be placed only on LVM pool") + thin_pool = self._volume.get('thin') use_vdo = self._volume['deduplication'] or self._volume['compression'] use_lvmraid = self._volume['raid_level'] diff --git a/tests/tests_lvm_errors.yml b/tests/tests_lvm_errors.yml index b85d86966..099126797 100644 --- a/tests/tests_lvm_errors.yml +++ b/tests/tests_lvm_errors.yml @@ -194,3 +194,31 @@ type: lvm disks: "{{ unused_disks }}" state: absent + + - name: Test for correct handling of pool and volume type mismatch + include_tasks: verify-role-failed.yml + vars: + storage_safe_mode: false + __storage_failed_regex: LVM volume can be placed only on LVM pool + __storage_failed_msg: Role did not report that wrong pool type was selected + __storage_failed_params: + storage_pools: + - name: foo + disks: "{{ unused_disks }}" + type: partition + volumes: + - name: test1 + type: lvm + size: "{{ volume1_size }}" + mount_point: "{{ mount_location1 }}" + + - name: Clean up + include_role: + name: linux-system-roles.storage + vars: + storage_safe_mode: false + storage_pools: + - name: testpool1 + type: lvm + disks: "{{ unused_disks }}" + state: absent