summaryrefslogtreecommitdiffstats
path: root/roles/openshift_health_checker
diff options
context:
space:
mode:
Diffstat (limited to 'roles/openshift_health_checker')
-rw-r--r--roles/openshift_health_checker/action_plugins/openshift_health_check.py3
-rw-r--r--roles/openshift_health_checker/openshift_checks/__init__.py7
-rw-r--r--roles/openshift_health_checker/openshift_checks/disk_availability.py13
-rw-r--r--roles/openshift_health_checker/openshift_checks/docker_image_availability.py37
-rw-r--r--roles/openshift_health_checker/openshift_checks/docker_storage.py2
-rw-r--r--roles/openshift_health_checker/openshift_checks/ovs_version.py3
-rw-r--r--roles/openshift_health_checker/openshift_checks/package_version.py3
-rw-r--r--roles/openshift_health_checker/test/disk_availability_test.py23
-rw-r--r--roles/openshift_health_checker/test/docker_image_availability_test.py46
-rw-r--r--roles/openshift_health_checker/test/ovs_version_test.py3
10 files changed, 119 insertions, 21 deletions
diff --git a/roles/openshift_health_checker/action_plugins/openshift_health_check.py b/roles/openshift_health_checker/action_plugins/openshift_health_check.py
index 326176273..3ee3b132c 100644
--- a/roles/openshift_health_checker/action_plugins/openshift_health_check.py
+++ b/roles/openshift_health_checker/action_plugins/openshift_health_check.py
@@ -101,7 +101,8 @@ class ActionModule(ActionBase):
execute_module=self._execute_module,
tmp=tmp,
task_vars=task_vars,
- want_full_results=want_full_results
+ want_full_results=want_full_results,
+ templar=self._templar
)
return known_checks
diff --git a/roles/openshift_health_checker/openshift_checks/__init__.py b/roles/openshift_health_checker/openshift_checks/__init__.py
index ce05b44a4..b7b16e0ea 100644
--- a/roles/openshift_health_checker/openshift_checks/__init__.py
+++ b/roles/openshift_health_checker/openshift_checks/__init__.py
@@ -65,12 +65,15 @@ class OpenShiftCheck(object):
If the check can gather logs, tarballs, etc., do so when True; but no need to spend
the time if they're not wanted (won't be written to output directory).
"""
-
- def __init__(self, execute_module=None, task_vars=None, tmp=None, want_full_results=False):
+ # pylint: disable=too-many-arguments
+ def __init__(self, execute_module=None, task_vars=None, tmp=None, want_full_results=False,
+ templar=None):
# store a method for executing ansible modules from the check
self._execute_module = execute_module
# the task variables and tmpdir passed into the health checker task
self.task_vars = task_vars or {}
+ # We may need to template some task_vars
+ self._templar = templar
self.tmp = tmp
# a boolean for disabling the gathering of results (files, computations) that won't
# actually be recorded/used
diff --git a/roles/openshift_health_checker/openshift_checks/disk_availability.py b/roles/openshift_health_checker/openshift_checks/disk_availability.py
index 7956559c6..87e6146d4 100644
--- a/roles/openshift_health_checker/openshift_checks/disk_availability.py
+++ b/roles/openshift_health_checker/openshift_checks/disk_availability.py
@@ -1,6 +1,7 @@
"""Check that there is enough disk space in predefined paths."""
import tempfile
+import os.path
from openshift_checks import OpenShiftCheck, OpenShiftCheckException
@@ -121,11 +122,21 @@ class DiskAvailability(OpenShiftCheck):
return {}
+ def find_ansible_submounts(self, path):
+ """Return a list of ansible_mounts that are below the given path."""
+ base = os.path.join(path, "")
+ return [
+ mount
+ for mount in self.get_var("ansible_mounts")
+ if mount["mount"].startswith(base)
+ ]
+
def free_bytes(self, path):
"""Return the size available in path based on ansible_mounts."""
+ submounts = sum(mnt.get('size_available', 0) for mnt in self.find_ansible_submounts(path))
mount = self.find_ansible_mount(path)
try:
- return mount['size_available']
+ return mount['size_available'] + submounts
except KeyError:
raise OpenShiftCheckException(
'Unable to retrieve disk availability for "{path}".\n'
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 7c8ac78fe..587c6f85c 100644
--- a/roles/openshift_health_checker/openshift_checks/docker_image_availability.py
+++ b/roles/openshift_health_checker/openshift_checks/docker_image_availability.py
@@ -1,5 +1,6 @@
"""Check that required Docker images are available."""
+import re
from pipes import quote
from ansible.module_utils import six
from openshift_checks import OpenShiftCheck
@@ -11,12 +12,16 @@ DEPLOYMENT_IMAGE_INFO = {
"origin": {
"namespace": "openshift",
"name": "origin",
- "registry_console_image": "cockpit/kubernetes",
+ "registry_console_template": "${prefix}kubernetes:${version}",
+ "registry_console_prefix": "cockpit/",
+ "registry_console_default_version": "latest",
},
"openshift-enterprise": {
"namespace": "openshift3",
"name": "ose",
- "registry_console_image": "registry.access.redhat.com/openshift3/registry-console",
+ "registry_console_template": "${prefix}registry-console:${version}",
+ "registry_console_prefix": "registry.access.redhat.com/openshift3/",
+ "registry_console_default_version": "${short_version}",
},
}
@@ -61,10 +66,15 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck):
# for the oreg_url registry there may be credentials specified
components = self.get_var("oreg_url", default="").split('/')
self.registries["oreg"] = "" if len(components) < 3 else components[0]
+
+ # Retrieve and template registry credentials, if provided
self.skopeo_command_creds = ""
oreg_auth_user = self.get_var('oreg_auth_user', default='')
oreg_auth_password = self.get_var('oreg_auth_password', default='')
if oreg_auth_user != '' and oreg_auth_password != '':
+ if self._templar is not None:
+ oreg_auth_user = self._templar.template(oreg_auth_user)
+ oreg_auth_password = self._templar.template(oreg_auth_password)
self.skopeo_command_creds = "--creds={}:{}".format(quote(oreg_auth_user), quote(oreg_auth_password))
# record whether we could reach a registry or not (and remember results)
@@ -146,10 +156,7 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck):
if 'oo_nodes_to_config' in host_groups:
for suffix in NODE_IMAGE_SUFFIXES:
required.add(image_url.replace("${component}", suffix).replace("${version}", image_tag))
- # The registry-console is for some reason not prefixed with ose- like the other components.
- # Nor is it versioned the same, so just look for latest.
- # Also a completely different name is used for Origin.
- required.add(image_info["registry_console_image"])
+ required.add(self._registry_console_image(image_tag, image_info))
# images for containerized components
if self.get_var("openshift", "common", "is_containerized"):
@@ -165,6 +172,24 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck):
return required
+ def _registry_console_image(self, image_tag, image_info):
+ """Returns image with logic to parallel what happens with the registry-console template."""
+ # The registry-console is for some reason not prefixed with ose- like the other components.
+ # Nor is it versioned the same. Also a completely different name is used for Origin.
+ prefix = self.get_var(
+ "openshift_cockpit_deployer_prefix",
+ default=image_info["registry_console_prefix"],
+ )
+
+ # enterprise template just uses v3.6, v3.7, etc
+ match = re.match(r'v\d+\.\d+', image_tag)
+ short_version = match.group() if match else image_tag
+ version = image_info["registry_console_default_version"].replace("${short_version}", short_version)
+ version = self.get_var("openshift_cockpit_deployer_version", default=version)
+
+ template = image_info["registry_console_template"]
+ return template.replace('${prefix}', prefix).replace('${version}', version)
+
def local_images(self, images):
"""Filter a list of images and return those available locally."""
found_images = []
diff --git a/roles/openshift_health_checker/openshift_checks/docker_storage.py b/roles/openshift_health_checker/openshift_checks/docker_storage.py
index 0558ddf14..6808d8b2f 100644
--- a/roles/openshift_health_checker/openshift_checks/docker_storage.py
+++ b/roles/openshift_health_checker/openshift_checks/docker_storage.py
@@ -14,7 +14,7 @@ class DockerStorage(DockerHostMixin, OpenShiftCheck):
"""
name = "docker_storage"
- tags = ["pre-install", "health", "preflight"]
+ tags = ["health", "preflight"]
dependencies = ["python-docker-py"]
storage_drivers = ["devicemapper", "overlay", "overlay2"]
diff --git a/roles/openshift_health_checker/openshift_checks/ovs_version.py b/roles/openshift_health_checker/openshift_checks/ovs_version.py
index 416805c4d..0cad19842 100644
--- a/roles/openshift_health_checker/openshift_checks/ovs_version.py
+++ b/roles/openshift_health_checker/openshift_checks/ovs_version.py
@@ -16,7 +16,8 @@ class OvsVersion(NotContainerizedMixin, OpenShiftCheck):
tags = ["health"]
openshift_to_ovs_version = {
- "3.6": ["2.6", "2.7"],
+ "3.7": ["2.6", "2.7", "2.8"],
+ "3.6": ["2.6", "2.7", "2.8"],
"3.5": ["2.6", "2.7"],
"3.4": "2.4",
}
diff --git a/roles/openshift_health_checker/openshift_checks/package_version.py b/roles/openshift_health_checker/openshift_checks/package_version.py
index 2f09b22fc..13a91dadf 100644
--- a/roles/openshift_health_checker/openshift_checks/package_version.py
+++ b/roles/openshift_health_checker/openshift_checks/package_version.py
@@ -16,7 +16,8 @@ class PackageVersion(NotContainerizedMixin, OpenShiftCheck):
openshift_to_ovs_version = {
(3, 4): "2.4",
(3, 5): ["2.6", "2.7"],
- (3, 6): ["2.6", "2.7"],
+ (3, 6): ["2.6", "2.7", "2.8"],
+ (3, 7): ["2.6", "2.7", "2.8"],
}
openshift_to_docker_version = {
diff --git a/roles/openshift_health_checker/test/disk_availability_test.py b/roles/openshift_health_checker/test/disk_availability_test.py
index 29a325a17..7acdb40ec 100644
--- a/roles/openshift_health_checker/test/disk_availability_test.py
+++ b/roles/openshift_health_checker/test/disk_availability_test.py
@@ -96,6 +96,24 @@ def test_cannot_determine_available_disk(desc, ansible_mounts, expect_chunks):
'size_available': 20 * 10**9 + 1,
}],
),
+ (
+ ['oo_masters_to_config'],
+ 0,
+ [{
+ 'mount': '/',
+ 'size_available': 2 * 10**9,
+ }, { # not enough directly on /var
+ 'mount': '/var',
+ 'size_available': 10 * 10**9 + 1,
+ }, {
+ # but subdir mounts add up to enough
+ 'mount': '/var/lib/docker',
+ 'size_available': 20 * 10**9 + 1,
+ }, {
+ 'mount': '/var/lib/origin',
+ 'size_available': 20 * 10**9 + 1,
+ }],
+ ),
])
def test_succeeds_with_recommended_disk_space(group_names, configured_min, ansible_mounts):
task_vars = dict(
@@ -104,9 +122,10 @@ def test_succeeds_with_recommended_disk_space(group_names, configured_min, ansib
ansible_mounts=ansible_mounts,
)
- result = DiskAvailability(fake_execute_module, task_vars).run()
+ check = DiskAvailability(fake_execute_module, task_vars)
+ check.run()
- assert not result.get('failed', False)
+ assert not check.failures
@pytest.mark.parametrize('name,group_names,configured_min,ansible_mounts,expect_chunks', [
diff --git a/roles/openshift_health_checker/test/docker_image_availability_test.py b/roles/openshift_health_checker/test/docker_image_availability_test.py
index dec99e5db..484aa72e0 100644
--- a/roles/openshift_health_checker/test/docker_image_availability_test.py
+++ b/roles/openshift_health_checker/test/docker_image_availability_test.py
@@ -1,6 +1,6 @@
import pytest
-from openshift_checks.docker_image_availability import DockerImageAvailability
+from openshift_checks.docker_image_availability import DockerImageAvailability, DEPLOYMENT_IMAGE_INFO
@pytest.fixture()
@@ -180,7 +180,7 @@ def test_registry_availability(image, registries, connection_test_failed, skopeo
'openshift/origin-deployer:vtest',
'openshift/origin-docker-registry:vtest',
'openshift/origin-haproxy-router:vtest',
- 'cockpit/kubernetes', # origin version of registry-console
+ 'cockpit/kubernetes:latest', # origin version of registry-console
])
),
( # set a different URL for images
@@ -190,7 +190,7 @@ def test_registry_availability(image, registries, connection_test_failed, skopeo
'foo.io/openshift/origin-deployer:vtest',
'foo.io/openshift/origin-docker-registry:vtest',
'foo.io/openshift/origin-haproxy-router:vtest',
- 'cockpit/kubernetes', # AFAICS this is not built from the URL
+ 'cockpit/kubernetes:latest', # AFAICS this is not built from the URL
])
),
(
@@ -201,7 +201,7 @@ def test_registry_availability(image, registries, connection_test_failed, skopeo
'openshift/origin-deployer:vtest',
'openshift/origin-docker-registry:vtest',
'openshift/origin-haproxy-router:vtest',
- 'cockpit/kubernetes',
+ 'cockpit/kubernetes:latest',
# containerized component images
'openshift/origin:vtest',
'openshift/node:vtest',
@@ -217,7 +217,7 @@ def test_registry_availability(image, registries, connection_test_failed, skopeo
'foo.io/openshift3/ose-docker-registry:f13ac45',
'foo.io/openshift3/ose-haproxy-router:f13ac45',
# registry-console is not constructed/versioned the same as the others.
- 'registry.access.redhat.com/openshift3/registry-console',
+ 'registry.access.redhat.com/openshift3/registry-console:vtest',
# containerized images aren't built from oreg_url
'openshift3/node:vtest',
'openshift3/openvswitch:vtest',
@@ -249,6 +249,42 @@ def test_required_images(deployment_type, is_containerized, groups, oreg_url, ex
assert expected == DockerImageAvailability(task_vars=task_vars).required_images()
+@pytest.mark.parametrize("task_vars, expected", [
+ (
+ dict(
+ openshift_deployment_type="origin",
+ openshift_image_tag="vtest",
+ ),
+ "cockpit/kubernetes:latest",
+ ), (
+ dict(
+ openshift_deployment_type="openshift-enterprise",
+ openshift_image_tag="vtest",
+ ),
+ "registry.access.redhat.com/openshift3/registry-console:vtest",
+ ), (
+ dict(
+ openshift_deployment_type="openshift-enterprise",
+ openshift_image_tag="v3.7.0-alpha.0",
+ openshift_cockpit_deployer_prefix="registry.example.com/spam/",
+ ),
+ "registry.example.com/spam/registry-console:v3.7",
+ ), (
+ dict(
+ openshift_deployment_type="origin",
+ openshift_image_tag="v3.7.0-alpha.0",
+ openshift_cockpit_deployer_prefix="registry.example.com/eggs/",
+ openshift_cockpit_deployer_version="spam",
+ ),
+ "registry.example.com/eggs/kubernetes:spam",
+ ),
+])
+def test_registry_console_image(task_vars, expected):
+ info = DEPLOYMENT_IMAGE_INFO[task_vars["openshift_deployment_type"]]
+ tag = task_vars["openshift_image_tag"]
+ assert expected == DockerImageAvailability(task_vars=task_vars)._registry_console_image(tag, info)
+
+
def test_containerized_etcd():
task_vars = dict(
openshift=dict(
diff --git a/roles/openshift_health_checker/test/ovs_version_test.py b/roles/openshift_health_checker/test/ovs_version_test.py
index 5a82a43bf..6f0457549 100644
--- a/roles/openshift_health_checker/test/ovs_version_test.py
+++ b/roles/openshift_health_checker/test/ovs_version_test.py
@@ -38,8 +38,9 @@ def test_invalid_openshift_release_format():
@pytest.mark.parametrize('openshift_release,expected_ovs_version', [
+ ("3.7", ["2.6", "2.7", "2.8"]),
("3.5", ["2.6", "2.7"]),
- ("3.6", ["2.6", "2.7"]),
+ ("3.6", ["2.6", "2.7", "2.8"]),
("3.4", "2.4"),
("3.3", "2.4"),
("1.0", "2.4"),