-
Notifications
You must be signed in to change notification settings - Fork 63
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
collect container definition limits #22
Conversation
@@ -643,6 +643,15 @@ def parse_container_definition(container_def, pod_id) | |||
parse_container_env_var(env_var) | |||
end | |||
|
|||
limits_hash = container_def.try(:resources).try(:limits).to_h | |||
new_result[:container_limit_items] = limits_hash.to_h.collect do |resource, value| |
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.
redundant .to_h
, already did it in line above
b202f81
to
25b7caf
Compare
BINARY_SUFFICES = ["Ki", "Mi", "Gi", "Ti", "Pi", "Ei"].freeze | ||
SI_SUFFICES = ["K", "M", "G", "T", "P", "E"].freeze | ||
|
||
def parse_quantity(resource) # convert to bytes\cores |
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.
@zeari can't we use iec_60027_2_to_i
as for the capacity fields?
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.
@simon3z we can but just for Ki,Mi,Gi...
i can try to get this code into https://github.com/ManageIQ/more_core_extensions instead
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.
@zeari yes let's extend that or anyway implement it in more_core_extensions
@@ -646,6 +650,28 @@ def parse_container_definition(container_def, pod_id) | |||
new_result | |||
end | |||
|
|||
BINARY_SUFFICES = ["Ki", "Mi", "Gi", "Ti", "Pi", "Ei"].freeze | |||
SI_SUFFICES = ["K", "M", "G", "T", "P", "E"].freeze |
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.
@zeari s/SUFFICES/SUFFIXES/ and I think we're missing m
(which is different from M
) and k
is lowercase. Anyway check the quantity.go
file.
7224621
to
c82bc10
Compare
@@ -646,6 +655,19 @@ def parse_container_definition(container_def, pod_id) | |||
new_result | |||
end | |||
|
|||
BINARY_SUFFIXES = ["Ki", "Mi", "Gi", "Ti", "Pi", "Ei"].freeze |
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.
@zeari this is spreading the internals of iec_60027_2_to_i
. What if iec_60027_2_to_i
will add a new suffix?
What if you try to parse iec_60027_2_to_i
and on ArgumentError
you fallback to decimal_si_to_f
?
Or anyway anything that keeps the logic in the iec_60027_2_to_i
module. E.g. adding a is_60027_2?
(Now that I think of it this second option seems nicer than the ArgumentError
)
|
||
# covert to milicores | ||
new_result[:limit_cpu] = (new_result[:limit_cpu] * 1000).to_i unless new_result[:limit_cpu].nil? | ||
new_result[:request_cpu] = (new_result[:request_cpu] * 1000).to_i unless new_result[:request_cpu].nil? |
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.
@zeari if we parse this with iec_60027_2_to_i
which is using floats we won't recover the rounding by multiplying by 1000
.
Either we do the entire parsing in integers or we may as well keep these in floats.
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.
i guess youre correct but are we expecting cpu to appear in binary form? thats seems weird to me. '1Mi'
cores?
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.
Limits are user-supplied, right?
If user is allowed to write 1Ki
, somebody will :-), and we should support it.
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.
so we can make a float version (iec_60027_2_to_f
) in core_extensions if thats what we want to do there. We can instead add a 'target units' option where we can choose in which units we want the result to be. for example "1.1111Mi".iec_60027_2_to_f("m")
would give us the result in milicores(milianything).
032ed97
to
e3c644c
Compare
LGTM 👍 waiting for the schema ManageIQ/manageiq-schema#25 to get merged. |
:privileged => container_def.securityContext.try(:privileged), | ||
:run_as_user => container_def.securityContext.try(:runAsUser), | ||
:run_as_non_root => container_def.securityContext.try(:runAsNonRoot), | ||
:security_context => parse_security_context(container_def.securityContext), |
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.
@zeari let's not make this dependent on the container definition removal.
If you just add the limit/request_cpu_cores
and limit/request_memory_bytes
then we can merge now.
close-cycling is unlikely to help, Travis fails on bin/setup due to ManageIQ/manageiq#15585 (comment) |
Also, we need a new |
This pull request is not mergeable. Please rebase and repush. |
|
LGTM but can you add a test? |
Added a test for |
Checked commit zeari@e2ddbf6 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
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.
LGTM 👍
Depends on and completes ManageIQ/manageiq#15180
More info: https://kubernetes.io/docs/tasks/administer-cluster/cpu-memory-limit/
@simon3z @cben @moolitayer