diff --git a/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb b/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb index 062d0d67280..46be38ca2ae 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb @@ -26,7 +26,6 @@ def ems_inv_to_hashes(inventory) get_endpoints(inventory) get_services(inventory) get_component_statuses(inventory) - get_registries get_images EmsRefresh.log_inv_debug_trace(@data, "data:") @data @@ -37,11 +36,6 @@ def get_images process_collection(images, :container_images) { |n| n } end - def get_registries - registries = @data_index.fetch_path(:container_image_registry, :by_host_and_port).try(:values) || [] - process_collection(registries, :container_image_registries) { |n| n } - end - def get_nodes(inventory) process_collection(inventory["node"], :container_nodes) { |n| parse_node(n) } @data[:container_nodes].each do |cn| @@ -692,6 +686,7 @@ def parse_container_image(image, imageID) if stored_container_image_registry.nil? @data_index.store_path( :container_image_registry, :by_host_and_port, host_port, container_image_registry) + process_collection_item(container_image_registry, :container_image_registries) { |r| r } stored_container_image_registry = container_image_registry end end diff --git a/spec/models/manageiq/providers/openshift/container_manager/refresh_parser_spec.rb b/spec/models/manageiq/providers/openshift/container_manager/refresh_parser_spec.rb index 1a90c0c0f25..8e19f1d7afd 100644 --- a/spec/models/manageiq/providers/openshift/container_manager/refresh_parser_spec.rb +++ b/spec/models/manageiq/providers/openshift/container_manager/refresh_parser_spec.rb @@ -166,6 +166,35 @@ parser.instance_variable_get('@data_index')[:container_image][:by_ref_and_registry_host_port].values[0]) expect(parser.instance_variable_get('@data')[:container_images][0][:architecture]).to eq('amd64') end + + context "image registries from openshift images" do + def parse_single_openshift_image_with_registry + inventory = {"image" => [image_from_openshift]} + + parser.get_openshift_images(inventory) + expect(parser.instance_variable_get('@data_index')[:container_image_registry][:by_host_and_port].size).to eq(1) + expect(parser.instance_variable_get('@data')[:container_image_registries].size).to eq(1) + end + + it "collects image registries from openshift images that are not also running pods images" do + parse_single_openshift_image_with_registry + end + + it "avoids duplicate image registries from both running pods and openshift images" do + parser.instance_variable_get('@data')[:container_image_registries] = [{ + :name => image_registry, + :host => image_registry, + :port => image_registry_port, + },] + parser.instance_variable_get('@data_index').store_path( + :container_image_registry, + :by_host_and_port, + "#{image_registry}:#{image_registry_port}", + parser.instance_variable_get('@data')[:container_image_registries][0] + ) + parse_single_openshift_image_with_registry + end + end end describe "parse_build" do