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

If size_is_minsize is true, consider the size in sync if already larg… #125

Merged
merged 1 commit into from
Oct 14, 2015

Conversation

dfairhurst
Copy link
Contributor

…er than desired size

Proposed fix for:
https://tickets.puppetlabs.com/browse/MODULES-2662

@@ -35,6 +35,27 @@
raise ArgumentError , "#{value} is not a valid logical volume size"
end
end
def insync?(is)
lvm_size_units = { "K" => 1, "M" => 1024, "G" => 1048576, "T" => 1073741824, "P" => 1099511627776, "E" => 1125899906842624 }
Copy link
Contributor

Choose a reason for hiding this comment

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

By convention all code is two spaces indents.

For clarity, please use 1024*1024, etc, instead of 1048576.

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 fixed the spacing, but I opted for 1024**2 etc. instead.

@DavidS
Copy link
Contributor

DavidS commented Oct 13, 2015

Congrats on getting all the tests green on your first try! The implementation looks fine in principle, I just nitpicked a few style issues. Please take care to use git commit --amend and git push --force when uploading your changes to this branch, to keep everything in one commit.

@dfairhurst
Copy link
Contributor Author

Updated as requested. One thing that I could possibly change is to use \d instead of what was existing [0-9].
Also, I removed accepting the "L" as a size unit in the validate, since it does not seem to be supported in the provider and I couldn't find what this L could mean. Let me know what you think about that.

current_size_bytes = $1.to_f
current_size_unit = $2.upcase
current_size_unit = $3.upcase
Copy link
Contributor

Choose a reason for hiding this comment

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

When tracking the unit handling code, I found another doozey in the overall code structure. Looking at https://github.com/puppetlabs/puppetlabs-lvm/pull/125/files#diff-d8b38c124d9da799f07a02cb607ba2deR125 , it uses lvs to convert the units, as lvm uses lowercase to denote multiples of 1024 and uppercase to denote multiples of 1000. o.O

See also http://linux.die.net/man/8/lvs --units.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it really an issue if all the lvm commands called are passed with a lowercase unit, or just as bytes?

I don't think the module should have to support uppercase meaning multiples of 1000 instead of 1024. It should always assume 1024 as long as it calls the correct lvm commands (i.e. don't use uppercase units when calling lvm)

Copy link
Contributor

Choose a reason for hiding this comment

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

This code - and that is not your fault! - makes my brain hurt. Indeed in L122, incoming units are always downcased.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:) anything else remaining or OK for merging?

DavidS added a commit that referenced this pull request Oct 14, 2015
If size_is_minsize is true, consider the size in sync if already larg…
@DavidS DavidS merged commit f59a852 into puppetlabs:master Oct 14, 2015
@DavidS
Copy link
Contributor

DavidS commented Oct 14, 2015

Thanks for your contribution!

@dfairhurst
Copy link
Contributor Author

Thanks for the review + merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants