Skip to content

Commit

Permalink
Merge branch 'fix_capacity_nil_5.5.z' into '5.5.z'
Browse files Browse the repository at this point in the history
OpenShift refresh broken on undefined memory capacity

Clean cherry-pick from upstream

fixes upstream issue - ManageIQ#5678
upstream PR - ManageIQ#5726
BZ - https://bugzilla.redhat.com/show_bug.cgi?id=1288045

See merge request !636
  • Loading branch information
Oleg Barenboim committed Dec 21, 2015
2 parents 9c91c55 + 33ea4b8 commit 16e3c04
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 3 deletions.
Expand Up @@ -144,12 +144,12 @@ def parse_node(node)
:lives_on_type => nil
)

node_memory = node.status.capacity.memory
node_memory = node.status.capacity.try(:memory)
node_memory &&= parse_iec_number(node_memory) / 1.megabyte

new_result[:computer_system] = {
:hardware => {
:cpu_total_cores => node.status.capacity.cpu,
:cpu_total_cores => node.status.capacity.try(:cpu),
:memory_mb => node_memory
},
:operating_system => {
Expand All @@ -158,7 +158,7 @@ def parse_node(node)
}
}

max_container_groups = node.status.capacity.pods
max_container_groups = node.status.capacity.try(:pods)
new_result[:max_container_groups] = max_container_groups && parse_iec_number(max_container_groups)

new_result[:container_conditions] = parse_conditions(node)
Expand Down
Expand Up @@ -540,4 +540,109 @@
end
end
end

describe "parse_node" do
it "handles node without capacity" do
parser.send(
:parse_node,
RecursiveOpenStruct.new(
:metadata => {
:name => 'test-node',
:uid => 'f0c1fe7e-9c09-11e5-bb22-28d2447dcefe',
:resourceVersion => '369104',
:creationTimestamp => '2015-12-06T11:10:21Z'
},
:spec => {
:externalID => '10.35.17.99'
},
:status => {
:nodeInfo => {
:machineID => 'id',
:systemUUID => 'uuid'
}
}
)
).should == {
:name => 'test-node',
:ems_ref => 'f0c1fe7e-9c09-11e5-bb22-28d2447dcefe',
:creation_timestamp => '2015-12-06T11:10:21Z',
:container_conditions => [],
:container_runtime_version => nil,
:identity_infra => '10.35.17.99',
:identity_machine => 'id',
:identity_system => 'uuid',
:kubernetes_kubelet_version => nil,
:kubernetes_proxy_version => nil,
:labels => [],
:lives_on_id => nil,
:lives_on_type => nil,
:max_container_groups => nil,
:computer_system => {
:hardware => {
:cpu_total_cores => nil,
:memory_mb => nil
},
:operating_system => {
:distribution => nil,
:kernel_version => nil
}
},
:namespace => nil,
:resource_version => '369104',
:type => 'ManageIQ::Providers::Kubernetes::ContainerManager::ContainerNode'
}
end

it "handles node without memory, cpu and pods" do
parser.send(
:parse_node,
RecursiveOpenStruct.new(
:metadata => {
:name => 'test-node',
:uid => 'f0c1fe7e-9c09-11e5-bb22-28d2447dcefe',
:resourceVersion => '3691041',
:creationTimestamp => '2015-12-06T11:10:21Z'
},
:spec => {
:externalID => '10.35.17.99'
},
:status => {
:nodeInfo => {
:machineID => 'id',
:systemUUID => 'uuid'
},
:capacity => {}
}
)
).should == {
:name => 'test-node',
:ems_ref => 'f0c1fe7e-9c09-11e5-bb22-28d2447dcefe',
:creation_timestamp => '2015-12-06T11:10:21Z',
:container_conditions => [],
:container_runtime_version => nil,
:identity_infra => '10.35.17.99',
:identity_machine => 'id',
:identity_system => 'uuid',
:kubernetes_kubelet_version => nil,
:kubernetes_proxy_version => nil,
:labels => [],
:lives_on_id => nil,
:lives_on_type => nil,
:max_container_groups => nil,
:computer_system => {
:hardware => {
:cpu_total_cores => nil,
:memory_mb => nil
},
:operating_system => {
:distribution => nil,
:kernel_version => nil
}
},
:namespace => nil,
:resource_version => '3691041',
:type => 'ManageIQ::Providers::Kubernetes::ContainerManager::ContainerNode'
}
end
end
end

0 comments on commit 16e3c04

Please sign in to comment.