-
Notifications
You must be signed in to change notification settings - Fork 243
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
refactor : Use strongunits.B
, strongunits.MiB
and strongunits.GiB
to store memory size (#1642)
#4554
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
strongunits.MiB
/ strongunits.GiB
to store memory size (#1642)strongunits.B
, strongunits.MiB
and strongunits.GiB
to store memory size (#1642)
ab1554a
to
090f992
Compare
@rohanKanojia I think that is one part of the #1642 but iirc what @cfergeau wanted for the user to provide memory/disk size in MB and GB like if user know that he need 10GB ram he can use memory setting as |
@praveenkumar : Are you talking about CRC config memory values? |
Ah right, I say in #1642 "to the option parsing code", so it must have been what I meant in this issue. However, having clear units throughout the code base is also very useful from a maintainance perspective, so imo both are good to have. |
Okay, I'm going to implement parsing and validation logic for these crc config values:
I have some doubts regarding the implementation:
|
As of now our call back functions handles misconfiguration around config and currently if user specify different value for ram/disk-size/persistent-volume then what we expect then we do error out. I don't mind to have this as it is because now atleast we have clear units through out code. Breaking changes is something we dont' want to do because lot of folks now use those config as part of scripts. |
I see. Understood that we don't want to add any breaking changes. So if user would provide integer value, CRC would consider it as currently configured MiB/GiB value. Would you like me to add the parsing only as a fallback option? Or maybe drop this idea altogether? |
090f992
to
48d8cf5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Just one minor comment.
pkg/crc/machine/status.go
Outdated
} | ||
|
||
return ram.([]int64)[0], ram.([]int64)[1] | ||
return strongunits.B(ram.([]uint64)[0]), strongunits.B(ram.([]uint64)[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use variables in this line for clarity:
return strongunits.B(ram.([]uint64)[0]), strongunits.B(ram.([]uint64)[1]) | |
used, total := ram.([]int64)[0], ram.([]int64)[1] | |
return strongunits.B(used), strongunits.B(total) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to review! I've updated it as per your suggestion.
48d8cf5
to
7859997
Compare
…size (crc-org#1642) Currently we're using memory values in `uint64` variable. This works but sometimes it can be confusing to figure out what unit we're using if variable is not named correctly. Instead, we can rely on strongunits types for byte,MegaByte and GigaByte for these values. Signed-off-by: Rohan Kumar <[email protected]>
7859997
to
269f5f8
Compare
@rohanKanojia: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
@rohanKanojia I don't think this is very high priority work as of now so I am going to merge this as it is . |
Description
Fixes: #1642
Currently, we're using memory values in
uint64
variable. This works but sometimes it can be confusing to figure out what unit we're using if variable is not named correctly.Instead, we can rely on containers/strongunits types for these values for byte,MegaByte and GigaByte.
Type of change
test, version modification, documentation, etc.)
Proposed changes
Please note that at the moment, I've only made changes at CRC levels. I haven't updated driver code. I plan to do it in follow up PRs.
strongunits.B
,strongunits.MiB
andstrongunits.GiB
-1
as a value for memory size to indicate null values. Use0
instead of-1
.Testing
I made sure all unit tests were passing and verified that cluster was getting started. I also ran basic e2e test locally on my machine to check if these changes were not breaking anything.
Contribution Checklist