Skip to content

Commit a07c80c

Browse files
committed
fix: Fix getting PVs from raid_disks for RAID LVs
Currently the code expects the disks specified in raid_disks are parent devices of the PVs we are going to use to allocate the RAID LVs. This might not be true in several cases, for example if the VG is encrypted (the LUKS device introduces a new layer in the storage stack) or if partitions are not used (the disk is then the PV and doesn't have a parent). This fix also allows user to specify the PV partition instead of the underlying disk.
1 parent fea3415 commit a07c80c

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

library/blivet.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,9 +1091,16 @@ def _get_params_lvmraid(self):
10911091

10921092
for path in self._volume['raid_disks']:
10931093
disk = self._blivet.devicetree.resolve_device(path)
1094-
for pv in parent_device.pvs:
1095-
if disk in pv.parents:
1096-
pvs.append(pv)
1094+
if disk:
1095+
for pv in parent_device.pvs:
1096+
if pv == disk or disk in pv.ancestors:
1097+
pvs.append(pv)
1098+
break
1099+
else:
1100+
raise BlivetAnsibleError("Disk %s specified in raid_disks doesn't seem "
1101+
"to be a PV of %s" % (path, parent_device.name))
1102+
else:
1103+
raise BlivetAnsibleError("disk %s specified in raid_disks not found" % path)
10971104

10981105
else:
10991106
pvs = parent_device.pvs

tests/tests_create_raid_pool_then_remove.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,46 @@
244244
- name: Verify role results
245245
include_tasks: verify-role-results.yml
246246

247+
- name: Create a RAID1 lvm raid device on encrypted VG
248+
include_role:
249+
name: linux-system-roles.storage
250+
vars:
251+
storage_pools:
252+
- name: vg1
253+
disks: "{{ unused_disks }}"
254+
type: lvm
255+
state: present
256+
encryption: true
257+
encryption_password: yabbadabbadoo
258+
volumes:
259+
- name: lv1
260+
size: "{{ volume1_size }}"
261+
mount_point: "{{ mount_location1 }}"
262+
raid_disks: "{{ [unused_disks[0], unused_disks[1]] }}"
263+
raid_level: raid0
264+
265+
- name: Verify role results
266+
include_tasks: verify-role-results.yml
267+
268+
- name: Remove the device created above
269+
include_role:
270+
name: linux-system-roles.storage
271+
vars:
272+
storage_pools:
273+
- name: vg1
274+
disks: "{{ unused_disks }}"
275+
type: lvm
276+
state: absent
277+
volumes:
278+
- name: lv1
279+
size: "{{ volume1_size }}"
280+
mount_point: "{{ mount_location1 }}"
281+
raid_level: raid0
282+
raid_disks: "{{ [unused_disks[0], unused_disks[1]] }}"
283+
284+
- name: Verify role results
285+
include_tasks: verify-role-results.yml
286+
247287
- name: Run test on supported platforms
248288
when: ((is_fedora and blivet_pkg_version is version("3.7.1-2", ">=")) or
249289
(is_rhel8 and blivet_pkg_version is version("3.6.0-5", ">=")) or

0 commit comments

Comments
 (0)