-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There is an usecase when the physical device size can change (e.g. on VM). We need to be able to change the size of the LVM PV to accomodate that. This adds a new pool parameter 'grow_to_fill'. When set, pool PVs will try to take all available space on their respective devices. Defaults to False. Requires blivet version that supports this feature. For tests this is checked by using 'does_library_support' script.
- Loading branch information
Showing
5 changed files
with
163 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
- name: Test create disk and remove | ||
hosts: all | ||
become: true | ||
vars: | ||
storage_safe_mode: false | ||
mount_location1: '/opt/test1' | ||
mount_location2: '/opt/test2' | ||
pv_size: '8g' | ||
volume1_size: '2g' | ||
volume2_size: '3g' | ||
tags: | ||
- tests::lvm | ||
|
||
tasks: | ||
- name: Run the role | ||
include_role: | ||
name: linux-system-roles.storage | ||
|
||
- name: Mark tasks to be skipped | ||
set_fact: | ||
storage_skip_checks: | ||
- blivet_available | ||
- service_facts | ||
- "{{ (lookup('env', | ||
'SYSTEM_ROLES_REMOVE_CLOUD_INIT') in ['', 'false']) | | ||
ternary('packages_installed', '') }}" | ||
|
||
- name: Get unused disks | ||
include_tasks: get_unused_disk.yml | ||
vars: | ||
max_return: 1 | ||
|
||
- name: Create PV with a space to grow | ||
command: "pvcreate --setphysicalvolumesize {{ pv_size }} /dev/{{ unused_disks[0] }}" | ||
register: pvcreate_output | ||
changed_when: pvcreate_output.rc != 0 | ||
|
||
# VG has to be present, the role otherwise automatically reformats empty PV, | ||
# taking all available space | ||
- name: Create VG | ||
command: "vgcreate foo /dev/{{ unused_disks[0] }}" | ||
register: vgcreate_output | ||
changed_when: vgcreate_output.rc != 0 | ||
|
||
- name: Create LVM | ||
include_role: | ||
name: linux-system-roles.storage | ||
vars: | ||
storage_pools: | ||
- name: foo | ||
disks: "{{ unused_disks }}" | ||
grow_to_fill: true | ||
state: present | ||
volumes: | ||
- name: test1 | ||
size: "{{ volume1_size }}" | ||
mount_point: "{{ mount_location1 }}" | ||
- name: test2 | ||
size: "{{ volume2_size }}" | ||
mount_point: "{{ mount_location2 }}" | ||
|
||
- name: Verify role results | ||
include_tasks: verify-role-results.yml | ||
|
||
- name: Rerun the task to verify idempotence | ||
include_role: | ||
name: linux-system-roles.storage | ||
vars: | ||
storage_pools: | ||
- name: foo | ||
disks: "{{ unused_disks }}" | ||
grow_to_fill: true | ||
state: present | ||
volumes: | ||
- name: test1 | ||
size: "{{ volume1_size }}" | ||
mount_point: "{{ mount_location1 }}" | ||
- name: test2 | ||
size: "{{ volume2_size }}" | ||
mount_point: "{{ mount_location2 }}" | ||
|
||
- name: Verify role results | ||
include_tasks: verify-role-results.yml | ||
|
||
- name: Remove 'foo' pool created above | ||
include_role: | ||
name: linux-system-roles.storage | ||
vars: | ||
storage_pools: | ||
- name: foo | ||
disks: "{{ unused_disks }}" | ||
state: "absent" | ||
volumes: | ||
- name: test1 | ||
- name: test2 | ||
|
||
- name: Verify role results | ||
include_tasks: verify-role-results.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
- name: Get actual PV size | ||
command: "pvs --noheadings --nosuffix --units b -o SIZE {{ st_pool_pv }}" | ||
register: actual_pv_size | ||
changed_when: false | ||
|
||
- name: Convert blkinfo size to bytes | ||
bsize: | ||
size: "{{ storage_test_blkinfo.info[st_pool_pv]['size'] }}" | ||
register: dev_size | ||
|
||
- name: Verify each PV size | ||
assert: | ||
that: (dev_size.bytes - actual_pv_size.stdout | int) | | ||
abs / actual_pv_size.stdout | int < 0.04 | ||
msg: >- | ||
PV resize failure; size difference too big | ||
(device size: {{ dev_size.bytes }}) | ||
(actual PV size: {{ actual_pv_size.stdout }}) | ||
- name: Clean up test variables | ||
set_fact: | ||
actual_pv_size: null | ||
dev_size: null |