Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions library/blivet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,9 +1091,16 @@

for path in self._volume['raid_disks']:
disk = self._blivet.devicetree.resolve_device(path)
for pv in parent_device.pvs:
if disk in pv.parents:
pvs.append(pv)
if disk:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Use explicit None check for resolved device

Use if disk is not None: to prevent issues if disk has a custom __bool__ method.

Suggested change
if disk:
if disk is not None:

for pv in parent_device.pvs:
if pv == disk or disk in pv.ancestors:
pvs.append(pv)
break

Check warning on line 1098 in library/blivet.py

View check run for this annotation

Codecov / codecov/patch

library/blivet.py#L1094-L1098

Added lines #L1094 - L1098 were not covered by tests
else:
raise BlivetAnsibleError("Disk %s specified in raid_disks doesn't seem "

Check warning on line 1100 in library/blivet.py

View check run for this annotation

Codecov / codecov/patch

library/blivet.py#L1100

Added line #L1100 was not covered by tests
"to be a PV of %s" % (path, parent_device.name))
else:
raise BlivetAnsibleError("disk %s specified in raid_disks not found" % path)

Check warning on line 1103 in library/blivet.py

View check run for this annotation

Codecov / codecov/patch

library/blivet.py#L1103

Added line #L1103 was not covered by tests

else:
pvs = parent_device.pvs
Expand Down
40 changes: 40 additions & 0 deletions tests/tests_create_raid_pool_then_remove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,46 @@
- name: Verify role results
include_tasks: verify-role-results.yml

- name: Create a RAID1 lvm raid device on encrypted VG
include_role:
name: linux-system-roles.storage
vars:
storage_pools:
- name: vg1
disks: "{{ unused_disks }}"
type: lvm
state: present
encryption: true
encryption_password: yabbadabbadoo
volumes:
- name: lv1
size: "{{ volume1_size }}"
mount_point: "{{ mount_location1 }}"
raid_disks: "{{ [unused_disks[0], unused_disks[1]] }}"
raid_level: raid0

- name: Verify role results
include_tasks: verify-role-results.yml

- name: Remove the device created above
include_role:
name: linux-system-roles.storage
vars:
storage_pools:
- name: vg1
disks: "{{ unused_disks }}"
type: lvm
state: absent
volumes:
- name: lv1
size: "{{ volume1_size }}"
mount_point: "{{ mount_location1 }}"
raid_level: raid0
raid_disks: "{{ [unused_disks[0], unused_disks[1]] }}"

- name: Verify role results
include_tasks: verify-role-results.yml

- name: Run test on supported platforms
when: ((is_fedora and blivet_pkg_version is version("3.7.1-2", ">=")) or
(is_rhel8 and blivet_pkg_version is version("3.6.0-5", ">=")) or
Expand Down
Loading