Skip to content

Commit

Permalink
Merge pull request #97 from dwlehman/resize-fixes
Browse files Browse the repository at this point in the history
Resize fixes
  • Loading branch information
pcahyna authored Aug 13, 2020
2 parents 7fe868a + 9a28aa2 commit 13b61f5
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 24 deletions.
12 changes: 10 additions & 2 deletions library/blivet.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,15 @@ def _resize(self):
except Exception:
raise BlivetAnsibleError("invalid size specification for volume '%s': '%s'" % (self._volume['name'], self._volume['size']))

if size and self._device.resizable and self._device.size != size:
if size and self._device.size != size:
try:
self._device.format.update_size_info()
except AttributeError:
pass

if not self._device.resizable:
return

if self._device.format.resizable:
self._device.format.update_size_info()

Expand Down Expand Up @@ -1178,7 +1186,7 @@ def action_dict(action):
result['packages'] = b.packages[:]

for action in scheduled:
if action.is_destroy and action.is_format and action.format.exists and \
if (action.is_destroy or action.is_resize) and action.is_format and action.format.exists and \
(action.format.mountable or action.format.type == "swap"):
action.format.teardown()

Expand Down
22 changes: 0 additions & 22 deletions tests/tests_lvm_errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -341,28 +341,6 @@
not blivet_output.changed }}"
msg: "Unexpected behavior w/ existing data on specified disks"

- name: Test for correct handling of safe_mode with resize
block:
- name: Try to resize in safe mode
include_role:
name: storage
vars:
storage_pools:
- name: testpool1
type: lvm
disks: "{{ unused_disks }}"
volumes:
- name: testvol1
fs_type: 'ext4'
size: '2g'

- name: Verify the output
assert:
that: "{{ not blivet_output.failed and blivet_output.changed }}"
msg: "Unexpected behavior w/ existing data on specified disks"

when: false

- name: Test for correct handling of safe_mode with existing pool
block:
- name: Try to create LVM pool on disks that already belong to an existing pool
Expand Down
63 changes: 63 additions & 0 deletions tests/tests_resize.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
- hosts: all
vars:
mount_location: '/opt/test1'
volume_group_size: '10g'
volume_size_before: '5g'
volume_size_after: '9g'

tasks:
- include_role:
name: storage

- include_tasks: get_unused_disk.yml
vars:
min_size: "{{ volume_group_size }}"
max_return: 1

- name: Create one LVM logical volume with "{{ volume_size_before }}" under one volume group
include_role:
name: storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
type: lvm
volumes:
- name: test1
# resizing is currently supported only for ext2/3/4
fs_type: 'ext4'
size: "{{ volume_size_before }}"
mount_point: "{{ mount_location }}"

- include_tasks: verify-role-results.yml

- name: Change volume_size to "{{ volume_size_after }}"
include_role:
name: storage
vars:
storage_pools:
- name: foo
type: lvm
disks: "{{ unused_disks }}"
volumes:
- name: test1
fs_type: 'ext4'
size: "{{ volume_size_after }}"
mount_point: "{{ mount_location }}"

- include_tasks: verify-role-results.yml

- name: Clean up
include_role:
name: storage
vars:
storage_pools:
- name: foo
disks: "{{ unused_disks }}"
state: absent
volumes:
- name: test1
size: "{{ volume_size_after }}"
mount_point: "{{ mount_location }}"

- include_tasks: verify-role-results.yml

0 comments on commit 13b61f5

Please sign in to comment.