lvol: Fix idempotency when size uses %VG or %PVS (#72569)

Change the behavior when using %VG or %PVS to make the `size_requested` an even
modulus of the VG's physical extents by rounding down.

This makes the usage of %VG or %PVS idempotent when the calculated
`size_requested` does not end on a physical extent boundary.

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: JuddTracy-DAS <38507478+JuddTracy-DAS@users.noreply.github.com>
pull/72883/head
Benoît Knecht 5 years ago committed by GitHub
parent 1e228e157a
commit 23e6e7db85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- lvol - fix idempotency issue when using lvol with ``%VG`` or ``%PVS`` size options and VG is fully allocated (https://github.com/ansible-collections/community.general/pull/229).

@ -477,6 +477,10 @@ def main():
size_requested = size_percent * this_vg['size'] / 100
else: # size_whole == 'FREE':
size_requested = size_percent * this_vg['free'] / 100
# Round down to the next lowest whole physical extent
size_requested -= (size_requested % this_vg['ext_size'])
if '+' in size:
size_requested += this_lv['size']
if this_lv['size'] < size_requested:

Loading…
Cancel
Save