Skip to content

Commit

Permalink
update docker image check
Browse files Browse the repository at this point in the history
This patch updates validation to ensure required docker images are
available in at least one of the registries supplied in the install
config. Due to limitations in the use of an api, as well as limitations
with the docker client, images are now pre-pulled as part of the check.

If a required image with a specific tag for the current version of
openshift is not found, or suffers an error while being pulled, the
check will fail and return the error from contacting docker daemon.
  • Loading branch information
juanvallejo committed Feb 23, 2017
1 parent ba74358 commit ff79ebc
Showing 1 changed file with 17 additions and 31 deletions.
@@ -1,8 +1,8 @@
# pylint: disable=missing-docstring
from openshift_checks import OpenShiftCheck, get_var
from openshift_checks.mixins import NotContainerized
from openshift_checks.mixins import NotContainerizedMixin

class DockerImageAvailability(NotContainerized, OpenShiftCheck):
class DockerImageAvailability(NotContainerizedMixin, OpenShiftCheck):
"""Check that required Docker images are available."""

name = "docker_image_availability"
Expand All @@ -11,39 +11,25 @@ class DockerImageAvailability(NotContainerized, OpenShiftCheck):
def run(self, tmp, task_vars):
openshift_release = get_var(task_vars, "openshift_release")

args = {
"name": self.rpm_docker_images(),
}
# attempt to pull each image and fail on
# the first one that cannot be fetched
for image in self.rpm_docker_images():
args = {
"name": image + ":" + openshift_release
}

docker_images = self.module_executor("docker_image_facts", args, tmp, task_vars)
res = self.module_executor("docker_image", args, tmp, task_vars)
if 'failed' in res:
return {"failed": True, "msg": "Failed to find required docker image for OpenShift version %s: %s" % (openshift_release, res['msg'])}

if len(docker_images['images']) == 0:
return {"failed": True, "msg": "Unable to find any docker images!"}

# if we find any docker images, attempt to do 1-to-1 match between
# each image description name key and items from rpm_docker_images
matched_images = set()
for i in docker_images['images']:
repoTag = i['RepoTags'][0]

# check image version
tag = repoTag.split(':')
if tag[1] == openshift_release and repoTag[0] in self.rpm_docker_images():
matched_images.add(tag[0])

missing_images = set(self.rpm_docker_images()) - matched_images
if len(missing_images) > 0:
return {"failed": True, "msg": "There are missing docker images or images that did not match the current OpenShift version (%s): %s:\n" % (openshift_release, missing_images)}

return {"Changed": False}
return {"Changed": True}

@staticmethod
def rpm_docker_images():
return [
"docker.io/openshift/origin",
"registry.access.redhat.com/openshift3/ose-haproxy-router",
"registry.access.redhat.com/openshift3/ose-deployer",
"registry.access.redhat.com/openshift3/ose-docker-registry",
"registry.access.redhat.com/openshift3/ose-pod",
"registry.access.redhat.com/openshift3/registry-console",
"openshift3/ose-haproxy-router",
"openshift3/ose-deployer",
"openshift3/ose-docker-registry",
"openshift3/ose-pod",
"openshift3/registry-console",
]

0 comments on commit ff79ebc

Please sign in to comment.