Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not check package version on non-master/node #3887

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ class PackageVersion(NotContainerizedMixin, OpenShiftCheck):
name = "package_version"
tags = ["preflight"]

@classmethod
def is_active(cls, task_vars):
"""Skip hosts that do not have package requirements."""
group_names = get_var(task_vars, "group_names", default=[])
master_or_node = 'masters' in group_names or 'nodes' in group_names
return super(PackageVersion, cls).is_active(task_vars) and master_or_node

def run(self, tmp, task_vars):
rpm_prefix = get_var(task_vars, "openshift", "common", "service_type")
openshift_release = get_var(task_vars, "openshift_release")
Expand Down
22 changes: 22 additions & 0 deletions roles/openshift_health_checker/test/package_version_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from openshift_checks.package_version import PackageVersion


Expand All @@ -19,3 +21,23 @@ def execute_module(module_name=None, module_args=None, tmp=None, task_vars=None)
check = PackageVersion(execute_module=execute_module)
result = check.run(tmp=None, task_vars=task_vars)
assert result is return_value


@pytest.mark.parametrize('group_names,is_containerized,is_active', [
(['masters'], False, True),
# ensure check is skipped on containerized installs
(['masters'], True, False),
(['nodes'], False, True),
(['masters', 'nodes'], False, True),
(['masters', 'etcd'], False, True),
([], False, False),
(['etcd'], False, False),
(['lb'], False, False),
(['nfs'], False, False),
])
def test_package_version_skip_when_not_master_nor_node(group_names, is_containerized, is_active):
task_vars = dict(
group_names=group_names,
openshift=dict(common=dict(is_containerized=is_containerized)),
)
assert PackageVersion.is_active(task_vars=task_vars) == is_active