Skip to content

Commit

Permalink
Option needed for new ems_refresh.openshift.store_unused_images setting
Browse files Browse the repository at this point in the history
Allows to still get_container_images=true, but instead of saving
metadata (labels etc) on all images openshift gave us,
save it only for images that have been mentioned by pods.

Here called store_new_images because this function doesn't have the
context to understand which images are "used".
For store_unused_images=false, it'll be called twice:
- from parse_pods with true, adding all images
- from parse_openshift_image with false, only enriching previous images
  • Loading branch information
cben committed Aug 28, 2017
1 parent 1c14c07 commit 004437c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,8 @@ def parse_container_state(state_hash)
res
end

def parse_container_image(image, imageID)
# may return nil if store_new_images = false
def parse_container_image(image, imageID, store_new_images: true)
container_image, container_image_registry = parse_image_name(image, imageID)
host_port = nil

Expand All @@ -1124,6 +1125,7 @@ def parse_container_image(image, imageID)
:container_image, :by_digest, container_image_identity)

if stored_container_image.nil?
return nil unless store_new_images
@data_index.store_path(
:container_image, :by_digest,
container_image_identity, container_image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,15 @@
expect(first_obj).to be(second_obj)
end
end

it "returns existing image or nil with store_new_images=false" do
obj1 = parser.parse_container_image(shared_image_without_host, shared_ref)
obj2 = parser.parse_container_image(shared_image_without_host, shared_ref, :store_new_images => false)
obj3 = parser.parse_container_image(shared_image_without_host, unique_ref, :store_new_images => false)
expect(obj1).not_to be nil
expect(obj2).to be obj2
expect(obj3).to be nil
end
end

describe "cross_link_node" do
Expand Down

0 comments on commit 004437c

Please sign in to comment.