From 9fbd9c25e39eb4e03af71e16ae8184659b056c77 Mon Sep 17 00:00:00 2001 From: Luke Meyer Date: Mon, 11 Sep 2017 17:28:28 -0400 Subject: docker_image_availability: fix local image search An image in the docker index may be tagged by name or by registry plus name. In order to find the image correctly locally and prevent looking for it externally, make sure all possible variations are searched. --- .../openshift_checks/docker_image_availability.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'roles/openshift_health_checker') diff --git a/roles/openshift_health_checker/openshift_checks/docker_image_availability.py b/roles/openshift_health_checker/openshift_checks/docker_image_availability.py index 4418fd7d5..9c35f0f92 100644 --- a/roles/openshift_health_checker/openshift_checks/docker_image_availability.py +++ b/roles/openshift_health_checker/openshift_checks/docker_image_availability.py @@ -139,10 +139,14 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck): def local_images(self, images): """Filter a list of images and return those available locally.""" - return [ - image for image in images - if self.is_image_local(image) - ] + registries = self.known_docker_registries() + found_images = [] + for image in images: + # docker could have the image name as-is or prefixed with any registry + imglist = [image] + [reg + "/" + image for reg in registries] + if self.is_image_local(imglist): + found_images.append(image) + return found_images def is_image_local(self, image): """Check if image is already in local docker index.""" @@ -151,7 +155,7 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck): def known_docker_registries(self): """Build a list of docker registries available according to inventory vars.""" - regs = list(self.get_var("openshift.docker.additional_registries")) + regs = list(self.get_var("openshift.docker.additional_registries", default=[])) deployment_type = self.get_var("openshift_deployment_type") if deployment_type == "origin" and "docker.io" not in regs: -- cgit v1.2.1