-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
skip "yum update" sanity check if not running on rhel #3757
skip "yum update" sanity check if not running on rhel #3757
Conversation
return {"changed": False, "msg": "Skipping check on unsupported OS: {os}".format(os=os)} | ||
|
||
def get_operating_system(self, task_vars): | ||
info = self.module_executor("docker_info", {}, task_vars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sosiouxme per your comment on the Trello card, since this is a pre-flight check, perhaps it would be better to use something like cat /proc/os-release
on the ansible host?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to call any module. The operating system / package manager is readily available in task_vars
, provided by http://docs.ansible.com/ansible/setup_module.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ ansible -i hosts -m setup master1 | grep yum
"ansible_pkg_mgr": "yum",
All we need to do is implement is_active
to look at task_vars['ansible_pkg_mgr']
.
@juanvallejo note that this is not about "not running on RHEL", but about the package manager... e.g., CentOS also uses "yum" and is perfectly compatible with the existing check. |
03a71f8
to
5e65384
Compare
5e65384
to
6e1e7c9
Compare
@@ -10,9 +10,13 @@ def is_active(cls, task_vars): | |||
return ( | |||
# This mixin is meant to be used with subclasses of OpenShiftCheck. | |||
super(NotContainerizedMixin, cls).is_active(task_vars) and | |||
not cls.is_containerized(task_vars) | |||
not cls.is_containerized(task_vars) and cls.has_yum_pkg_mgr(task_vars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be in a separate mixin, like say:
class NeedsYumMixin(object):
"""Mixin for checks that are only active for hosts where yum package manager is present."""
@classmethod
def is_active(cls, task_vars):
# This mixin is meant to be used with subclasses of OpenShiftCheck.
return super(NeedsYumMixin, cls).is_active(task_vars) and cls.has_yum_pkg_mgr(task_vars)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly
6e1e7c9
to
2ef0612
Compare
|
||
|
||
class PackageAvailability(NotContainerizedMixin, OpenShiftCheck): | ||
class PackageAvailability(NotContainerizedMixin, NeedsYumMixin, OpenShiftCheck): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Fedora you can technically still use yum
but instead of ignoring the check shouldn't you just use dnf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is about having the Python package yum
available/installed. Not that we couldn't support DNF, just that we don't have code for it at the moment.
This PR makes the check be skipped instead of giving an spurious error.
return ( | ||
# This mixin is meant to be used with subclasses of OpenShiftCheck. | ||
super(NeedsYumMixin, cls).is_active(task_vars) and | ||
not cls.is_containerized(task_vars) and cls.has_yum_pkg_mgr(task_vars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juanvallejo this mixin should do one thing -- it has nothing to do with 'containerized'.
We can remove this part of the condition here and remove the is_containerized
method.
Note how we use the two mixins together to compose their effects:
class PackageAvailability(NotContainerizedMixin, NeedsYumMixin, OpenShiftCheck):
...
|
||
@staticmethod | ||
def has_yum_pkg_mgr(task_vars): | ||
return task_vars["ansible_pkg_mgr"] == "yum" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could simply inline this:
@classmethod
def is_active(cls, task_vars):
return super(NeedsYumMixin, cls).is_active(task_vars) and task_vars["ansible_pkg_mgr"] == "yum"
@juanvallejo this could be done similar to #3887. |
09b1c6e
to
28af129
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two nits, otherwise LGTM
('yum', False, True), | ||
('yum', True, False), | ||
('dnf', False, False), | ||
('dnf', False, False), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two lines above are identical :-)
def test_is_active(pkg_mgr, is_containerized, is_active): | ||
task_vars = dict( | ||
ansible_pkg_mgr=pkg_mgr, | ||
group_names=["masters", "nodes"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is irrelevant to determine is_active
, right? If so, we can have one less line to read ;)
28af129
to
daebc9f
Compare
@rhcarvalho thanks for the feedback, comments addressed |
aos-ci-test |
[merge] |
[test]ing while waiting on the merge queue |
Evaluated for openshift ansible test up to daebc9f |
continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_openshift_ansible/11/) (Base Commit: 5fe1609) |
Flake openshift/origin#13731. [merge] again |
Evaluated for openshift ansible merge up to daebc9f |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_openshift_ansible/207/) (Base Commit: 5ffbb64) |
Related Trello card: https://trello.com/c/5pr2WcQH/43-diagnostics-additional-pre-flight-checks
Detect ansible host's OS using output of
docker info
and skip check if it is not being run on RHEL.cc @brenton @sosiouxme @rhcarvalho