Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: PV resize support #438

Merged
merged 2 commits into from
Jun 11, 2024

Conversation

japokorn
Copy link
Collaborator

@japokorn japokorn commented Apr 30, 2024

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.

Storage role development often relies on blivet library and changes in
it. Whether or not is specific feature supported by blivet is usually determined
by blivet version. That is a cumbersome process, especially when the feature
has not yet been added into blivet and the version has to be guessed.

Added script does_library_support verifies existence of the feature by using python
introspection and asking for existence of specific item in the library
(e.g. blivet.formats.lvmpv.LVMPhysicalVolume.grow_to_fill).
The script is supposed to be used for the tests only.

Blivet PR: #1229
JIRA issue: STORAGECFG-743

@japokorn japokorn changed the title PV resize support feat: PV resize support Apr 30, 2024
@japokorn japokorn force-pushed the main-support_pvresize branch 2 times, most recently from 4c0455a to da3bbc8 Compare April 30, 2024 15:47
Copy link

codecov bot commented Apr 30, 2024

Codecov Report

Attention: Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.

Project coverage is 11.57%. Comparing base (acd20be) to head (957534e).
Report is 18 commits behind head on main.

Current head 957534e differs from pull request most recent head 0572eca

Please upload reports for the commit 0572eca to get more accurate results.

Files Patch % Lines
library/blivet.py 0.00% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #438      +/-   ##
==========================================
- Coverage   16.54%   11.57%   -4.98%     
==========================================
  Files           2        8       +6     
  Lines         284     1806    +1522     
  Branches       79        0      -79     
==========================================
+ Hits           47      209     +162     
- Misses        237     1597    +1360     
Flag Coverage Δ
sanity ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@japokorn japokorn force-pushed the main-support_pvresize branch 2 times, most recently from 76af2bf to c1815c9 Compare April 30, 2024 16:15
@japokorn japokorn marked this pull request as ready for review April 30, 2024 16:31
@japokorn japokorn requested a review from richm May 2, 2024 09:28
@spetrosi
Copy link
Contributor

spetrosi commented May 2, 2024

[citest]

@japokorn japokorn marked this pull request as draft May 3, 2024 13:05
scripts/does_library_support.py
blivet.formats.lvmpv.LVMPhysicalVolume.grow_to_fill
register: grow_supported
changed_when: false
Copy link
Contributor

Choose a reason for hiding this comment

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

Using script with python scripts is tricky because the python interpreter path is different on every platform. The snapshot role uses script and has quite a bit of logic to determine which python interpreter to use.

https://github.com/linux-system-roles/snapshot/blob/main/tasks/main.yml#L21
The default value for __snapshot_python is defined here: https://github.com/linux-system-roles/snapshot/blob/main/vars/main.yml#L6

override for el7: https://github.com/linux-system-roles/snapshot/blob/main/vars/RedHat_7.yml#L4 and https://github.com/linux-system-roles/snapshot/blob/main/vars/CentOS_7.yml#L4

override for el8: https://github.com/linux-system-roles/snapshot/blob/main/vars/CentOS_8.yml#L4 and https://github.com/linux-system-roles/snapshot/blob/main/vars/RedHat_8.yml#L4

You might ask - well, why doesn't script use the Ansible python interpreter on the remote system? If you can figure out how to do that, good - I could not figure out how to do that, which is why we implemented the snapshot role the way we did.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did a bit of testing and it seems that the value we are looking for is in ansible_python.executable.
I have added

      args:
        executable: "{{ ansible_python.executable }}"

to see how it fares.


- name: Verify that PVs fill the whole devices when they should
include_tasks: verify-pool-member-pvsize.yml
loop: "{{ _storage_test_pool_pvs | default([], true) }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't need to use the form default([], true) here - just default([]) should work - if _storage_test_pool_pvs is defined, it should be a list - if it is an empty list (which evaluates to false in a boolean context, which is what the , true is for in the default filter), then nothing will be done - the loop will not be executed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.
(Removed unnecessary true)


- name: Clean up test variables
set_fact:
actual_pv_size: null
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
actual_pv_size: null
actual_pv_size: null
dev_size: null

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.
(Added missing dev_size: null)

@japokorn
Copy link
Collaborator Author

japokorn commented May 6, 2024

[citest]

@japokorn japokorn marked this pull request as ready for review May 10, 2024 10:57
library/blivet.py Show resolved Hide resolved
library/blivet.py Show resolved Hide resolved
@richm
Copy link
Contributor

richm commented Jun 3, 2024

[citest]

@japokorn
Copy link
Collaborator Author

japokorn commented Jun 4, 2024

Issues seem unrelated to this change since they are currently happening in the main branch as well.

@richm
Copy link
Contributor

richm commented Jun 6, 2024

please rebase on top of the latest main branch to pick up test fixes

@richm
Copy link
Contributor

richm commented Jun 11, 2024

@japokorn please rebase on top of latest main branch and then we can merge

Storage role development often relies on blivet library and changes in
it. Whether or not is specific feature supported by blivet is usually determined
by its version. That is a cumbersome process, especially when the feature
has not yet been added into blivet and the version has to be guessed.

Added script verifies existence of the feature by using python
introspection and asking for existence of specific item in the library
(e.g. 'blivet.formats.lvmpv.LVMPhysicalVolume.grow_to_fill').
The script is supposed to be used for the tests only.
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.
@richm richm merged commit 15b1738 into linux-system-roles:main Jun 11, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants