Skip to content

Commit

Permalink
feat: Add support for adding new devices to existing Stratis pools
Browse files Browse the repository at this point in the history
Related: RHEL-31854
  • Loading branch information
vojtechtrefny committed May 16, 2024
1 parent aedc7f8 commit 76976c5
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
27 changes: 27 additions & 0 deletions library/blivet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1923,6 +1923,33 @@ def _member_management_is_destructive(self):

return False

def _manage_members(self):
""" Schedule actions as needed to configure this pool's members. """
if not self._device:
return

add_disks = [d for d in self._disks if d not in self._device.ancestors]
remove_disks = [bd for bd in self._device.blockdevs if not any(d in bd.ancestors for d in self._disks)]

if remove_disks:
raise BlivetAnsibleError("cannot remove members '%s' from pool '%s': Stratis doesn't "
"support removing members from existing pools" %
(", ".join(d.name for d in remove_disks),
self._device.name))

if not add_disks:
return

for disk in add_disks:
member = self._create_one_member(disk)
try:
ac = ActionAddMember(self._device, member)
self._blivet.devicetree.actions.add(ac)
except Exception as e:
raise BlivetAnsibleError("failed to add disk '%s' to pool '%s': %s" % (disk.name,
self._pool['name'],
str(e)))

def _get_format(self):
fmt = get_format("stratis")
if not fmt.supported or not fmt.formattable:
Expand Down
46 changes: 46 additions & 0 deletions tests/tests_stratis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,49 @@

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

# XXX blivet supporting this is not yet released
- name: Run test only if blivet supports this functionality
when: false
block:
- name: Create one Stratis pool on one disk
include_role:
name: linux-system-roles.storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks[0] }}"
type: stratis

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

- name: Add the second disk to the pool
include_role:
name: linux-system-roles.storage
vars:
storage_pools:
- name: foo
disks: "{{ [unused_disks[0], unused_disks[1]] }}"
type: stratis

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

- name: Clean up
include_role:
name: linux-system-roles.storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
type: stratis
state: absent
volumes:
- name: test1
size: "{{ volume_size }}"
mount_point: "{{ mount_location }}"
state: absent

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

0 comments on commit 76976c5

Please sign in to comment.