From 1e8759e88e52b5f37916d35a228fef0e719d312e Mon Sep 17 00:00:00 2001 From: JuddTracy-DAS <38507478+JuddTracy-DAS@users.noreply.github.com> Date: Thu, 23 Apr 2020 15:39:44 -0400 Subject: [PATCH 1/5] Fix rounding issues with percentages Changed the behavior when using %VG or %PVS to make the size_requested an even modulus with the VGs physical extents by rounding down. This makes the usage of %VG or $PVE idempotent when the calculated size_requested does not end on a physical extent boundary. --- plugins/modules/system/lvol.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/modules/system/lvol.py b/plugins/modules/system/lvol.py index 26ea7dc24ef..2e9ad9189ac 100644 --- a/plugins/modules/system/lvol.py +++ b/plugins/modules/system/lvol.py @@ -468,6 +468,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: From 1396127cf6640db098360ff72db116a2dc56b32b Mon Sep 17 00:00:00 2001 From: Judd Tracy Date: Thu, 18 Jun 2020 20:08:47 +0000 Subject: [PATCH 2/5] Added ansible changelog fragment. --- changelogs/fragments/229_lvol_percentage_fix.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/229_lvol_percentage_fix.yml diff --git a/changelogs/fragments/229_lvol_percentage_fix.yml b/changelogs/fragments/229_lvol_percentage_fix.yml new file mode 100644 index 00000000000..bc54528f3f4 --- /dev/null +++ b/changelogs/fragments/229_lvol_percentage_fix.yml @@ -0,0 +1,2 @@ +minor_changes: + - Fix idempotent issue when using lvol with %VG or %PVS size options and VG is fully allocated. From e203e8f1c0dbcb0e525eb6fb23f8d754bebb260a Mon Sep 17 00:00:00 2001 From: Judd Tracy Date: Thu, 18 Jun 2020 20:10:09 +0000 Subject: [PATCH 3/5] Forgot the module in the changelog fragment. --- changelogs/fragments/229_lvol_percentage_fix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/229_lvol_percentage_fix.yml b/changelogs/fragments/229_lvol_percentage_fix.yml index bc54528f3f4..51d3c6cd2a4 100644 --- a/changelogs/fragments/229_lvol_percentage_fix.yml +++ b/changelogs/fragments/229_lvol_percentage_fix.yml @@ -1,2 +1,2 @@ minor_changes: - - Fix idempotent issue when using lvol with %VG or %PVS size options and VG is fully allocated. + - lvol - Fix idempotent issue when using lvol with %VG or %PVS size options and VG is fully allocated. From 0ae6449dea49faecd5e11dc7f19d0616ee7814b1 Mon Sep 17 00:00:00 2001 From: Judd Tracy Date: Fri, 19 Jun 2020 13:23:59 +0000 Subject: [PATCH 4/5] Added URL to the PR to the changelog fragment. --- changelogs/fragments/229_lvol_percentage_fix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/229_lvol_percentage_fix.yml b/changelogs/fragments/229_lvol_percentage_fix.yml index 51d3c6cd2a4..f1212ecea82 100644 --- a/changelogs/fragments/229_lvol_percentage_fix.yml +++ b/changelogs/fragments/229_lvol_percentage_fix.yml @@ -1,2 +1,2 @@ minor_changes: - - lvol - Fix idempotent issue when using lvol with %VG or %PVS size options and VG is fully allocated. + - lvol - Fix idempotent issue when using lvol with %VG or %PVS size options and VG is fully allocated (https://github.com/ansible-collections/community.general/pull/229). From bec9d8b8d28d0413a7390c1034769713f6d6f7a8 Mon Sep 17 00:00:00 2001 From: JuddTracy-DAS <38507478+JuddTracy-DAS@users.noreply.github.com> Date: Mon, 19 Oct 2020 08:52:36 -0400 Subject: [PATCH 5/5] Update changelogs/fragments/229_lvol_percentage_fix.yml Co-authored-by: Felix Fontein --- changelogs/fragments/229_lvol_percentage_fix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/229_lvol_percentage_fix.yml b/changelogs/fragments/229_lvol_percentage_fix.yml index f1212ecea82..aaf98454ed4 100644 --- a/changelogs/fragments/229_lvol_percentage_fix.yml +++ b/changelogs/fragments/229_lvol_percentage_fix.yml @@ -1,2 +1,2 @@ minor_changes: - - lvol - Fix idempotent issue when using lvol with %VG or %PVS size options and VG is fully allocated (https://github.com/ansible-collections/community.general/pull/229). + - 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).