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

lvol - extending volumes with '+' only work for percentages #2267

Merged
merged 6 commits into from
Apr 26, 2021

Conversation

zigaSRC
Copy link
Contributor

@zigaSRC zigaSRC commented Apr 19, 2021

SUMMARY

Recreating PR ansible/ansible#54402 from old repo.

Modified lvol.py to accept '+' on absolute values and also added simple recalculations from e.g. MebiByte to MegaByte (for Kilo, Giga, Terra,...) to have consistency between lvs --units M/m and given Size M/m to lvextend (K/k, G/g, E/e, ...)

Closes #1988

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lvol

ADDITIONAL INFORMATION

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added affects_2.10 bug This issue/PR relates to a bug community_review module module needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) system labels Apr 19, 2021
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Can you please add a changelog fragment?

Also, is this really a bug, or more like a feature? I would tend to the latter.

@zigaSRC
Copy link
Contributor Author

zigaSRC commented Apr 20, 2021

@felixfontein Will add the changelog after implementing completely. Will also edit to change to feature.

@ansibullbot

This comment has been minimized.

@ansibullbot ansibullbot added ci_verified Push fixes to PR branch to re-run CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed community_review labels Apr 20, 2021
@@ -477,9 +502,9 @@ def main():
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'])
size_requested -= (size_requested % this_vg['ext_size']) # I'm not sure why we are trying to calculate the size instead of letting the tool do it and pass it the VG|PVS|FREE options. In my opinion it will only lead to confusion since the module logic might not match the tools and descreptencies might arise (not actually taking all the free space but an extent less or some such scenario). We can leave the test/error logic, but the tool already does that as well. Besides you're not doing any checks for size for the -L option either, it keeps the code simple and I preffer that approach. Do you dissagree, any suggestions? At the very least we should use the same approach for both -l and -L for consistency. Will implement after a discussion.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would appreciate some input :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

A more readable version (increases the chance that someone actually reads it):

I'm not sure why we are trying to calculate the size instead of letting the tool do it and pass it the VG|PVS|FREE options. In my opinion it will only lead to confusion since the module logic might not match the tools and descreptencies might arise (not actually taking all the free space but an extent less or some such scenario). We can leave the test/error logic, but the tool already does that as well. Besides you're not doing any checks for size for the -L option either, it keeps the code simple and I preffer that approach. Do you dissagree, any suggestions? At the very least we should use the same approach for both -l and -L for consistency. Will implement after a discussion.

(I'm not using this module and don't really know much about its internals, so I probably won't take part in this discussion.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

No clue either - the only thing I know for sure is that this (long) comment is not helping at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added it as a comment since otherwise, I could not create the comment/review request on github on that line.

Since there wasn't any input I tried implementing the feature with the minimum amount of changes made. See latest commits.

@ansibullbot ansibullbot added the feature This issue/PR relates to a feature request label Apr 20, 2021
@felixfontein felixfontein removed the bug This issue/PR relates to a bug label Apr 20, 2021
@ansibullbot ansibullbot removed the ci_verified Push fixes to PR branch to re-run CI label Apr 22, 2021
@ansibullbot ansibullbot added community_review and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Apr 22, 2021
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. and removed check-before-release PR will be looked at again shortly before release and merged if possible. labels Apr 24, 2021
@felixfontein felixfontein merged commit ffd7329 into ansible-collections:main Apr 26, 2021
@felixfontein
Copy link
Collaborator

@zigaSRC @unkaputtbar112 thanks for implementing this!
@russoz @jimjamg thanks for reviewing!

@unkaputtbar112
Copy link

Yeah, thanks for officially implementing it :)

I lost track of it, to be honest and yes @zigaSRC i was just starting with python and the calculations were stupid. I thought, someone else will probably pick it up and do it better anyway ;D

Copy link
Contributor Author

@zigaSRC zigaSRC left a comment

Choose a reason for hiding this comment

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

...

if size[-1].lower() in 'bskmgtpe':
size_unit = size[-1].lower()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

#2360
Should not have been removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or better yet add .lower on the 406th line, where LVS command is being used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_review feature This issue/PR relates to a feature request module module new_contributor Help guide this first time contributor plugins plugin (any type) system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lvol - extending volumes with '+' only work for percentages
5 participants