Skip to content

Commit 98136f0

Browse files
committed
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
1 parent 758d683 commit 98136f0

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

library/blivet.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,9 @@ def _create(self):
11751175
if self._device:
11761176
return
11771177

1178+
if self._blivet_pool._device and self._blivet_pool._device.type != "lvmvg":
1179+
raise BlivetAnsibleError("LVM volume can be placed only on LVM pool")
1180+
11781181
thin_pool = self._volume.get('thin')
11791182
use_vdo = self._volume['deduplication'] or self._volume['compression']
11801183
use_lvmraid = self._volume['raid_level']

tests/tests_lvm_errors.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,31 @@
194194
type: lvm
195195
disks: "{{ unused_disks }}"
196196
state: absent
197+
198+
- name: Test for correct handling of pool and volume type mismatch
199+
include_tasks: verify-role-failed.yml
200+
vars:
201+
storage_safe_mode: false
202+
__storage_failed_regex: LVM volume can be placed only on LVM pool
203+
__storage_failed_msg: Role did not report that wrong pool type was selected
204+
__storage_failed_params:
205+
storage_pools:
206+
- name: foo
207+
disks: "{{ unused_disks }}"
208+
type: partition
209+
volumes:
210+
- name: test1
211+
type: lvm
212+
size: "{{ volume1_size }}"
213+
mount_point: "{{ mount_location1 }}"
214+
215+
- name: Clean up
216+
include_role:
217+
name: linux-system-roles.storage
218+
vars:
219+
storage_safe_mode: false
220+
storage_pools:
221+
- name: testpool1
222+
type: lvm
223+
disks: "{{ unused_disks }}"
224+
state: absent

0 commit comments

Comments
 (0)