Skip to content

Commit

Permalink
collect container defninition limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Ari Zellner committed Jul 27, 2017
1 parent 00df730 commit 5481e7e
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1025,9 +1025,14 @@ def parse_container_spec(container_spec, pod_id)
:privileged => container_spec.securityContext.try(:privileged),
:run_as_user => container_spec.securityContext.try(:runAsUser),
:run_as_non_root => container_spec.securityContext.try(:runAsNonRoot),
:security_context => parse_security_context(container_spec.securityContext)
:security_context => parse_security_context(container_spec.securityContext),
:limit_cpu_cores => parse_quantity(container_spec.try(:resources).try(:limits).try(:cpu)),
:limit_memory_bytes => parse_quantity(container_spec.try(:resources).try(:limits).try(:memory)),
:request_cpu_cores => parse_quantity(container_spec.try(:resources).try(:requests).try(:cpu)),
:request_memory_bytes => parse_quantity(container_spec.try(:resources).try(:requests).try(:memory))
}
ports = container_spec.ports

new_result[:container_port_configs] = Array(ports).collect do |port_entry|
parse_container_port_config(port_entry, pod_id, container_spec.name)
end
Expand All @@ -1039,6 +1044,16 @@ def parse_container_spec(container_spec, pod_id)
new_result
end

def parse_quantity(resource) # parse a string with a suffix into a int\float
return nil if resource.nil?

begin
resource.iec_60027_2_to_i
rescue
resource.decimal_si_to_f
end
end

def parse_container_status(container, pod_id)
h = {
:type => 'ManageIQ::Providers::Kubernetes::ContainerManager::Container',
Expand Down

0 comments on commit 5481e7e

Please sign in to comment.