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

skip "yum update" sanity check if not running on rhel #3757

Conversation

juanvallejo
Copy link
Contributor

@juanvallejo juanvallejo commented Mar 23, 2017

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

@juanvallejo juanvallejo changed the title skip "yum update" sanity check if not running on rhel [WIP] skip "yum update" sanity check if not running on rhel Mar 23, 2017
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)
Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor

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'].

@rhcarvalho
Copy link
Contributor

@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.

@juanvallejo juanvallejo force-pushed the jvallejo/skip-yum-update-check-on-fedora branch 2 times, most recently from 03a71f8 to 5e65384 Compare March 24, 2017 23:17
@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 29, 2017
@juanvallejo juanvallejo force-pushed the jvallejo/skip-yum-update-check-on-fedora branch from 5e65384 to 6e1e7c9 Compare March 31, 2017 14:06
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 31, 2017
@@ -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)
Copy link
Member

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly

@juanvallejo juanvallejo force-pushed the jvallejo/skip-yum-update-check-on-fedora branch from 6e1e7c9 to 2ef0612 Compare April 6, 2017 21:41


class PackageAvailability(NotContainerizedMixin, OpenShiftCheck):
class PackageAvailability(NotContainerizedMixin, NeedsYumMixin, OpenShiftCheck):
Copy link
Contributor

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?

Copy link
Contributor

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)
Copy link
Contributor

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"
Copy link
Contributor

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"

@rhcarvalho
Copy link
Contributor

@juanvallejo this could be done similar to #3887.

@juanvallejo juanvallejo force-pushed the jvallejo/skip-yum-update-check-on-fedora branch 2 times, most recently from 09b1c6e to 28af129 Compare April 10, 2017 19:10
@juanvallejo juanvallejo changed the title [WIP] skip "yum update" sanity check if not running on rhel skip "yum update" sanity check if not running on rhel Apr 11, 2017
Copy link
Contributor

@rhcarvalho rhcarvalho left a 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),
Copy link
Contributor

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"],
Copy link
Contributor

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 ;)

@juanvallejo juanvallejo force-pushed the jvallejo/skip-yum-update-check-on-fedora branch from 28af129 to daebc9f Compare April 11, 2017 14:33
@juanvallejo
Copy link
Contributor Author

@rhcarvalho thanks for the feedback, comments addressed

@rhcarvalho
Copy link
Contributor

aos-ci-test

@rhcarvalho
Copy link
Contributor

[merge]

@openshift-bot
Copy link

[test]ing while waiting on the merge queue

@openshift-bot
Copy link

Evaluated for openshift ansible test up to daebc9f

@openshift-bot
Copy link

error: aos-ci-jenkins/OS_3.6_containerized for daebc9f (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.5_NOT_containerized, aos-ci-jenkins/OS_3.5_NOT_containerized_e2e_tests" for daebc9f (logs)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.5_containerized, aos-ci-jenkins/OS_3.5_containerized_e2e_tests" for daebc9f (logs)

@openshift-bot
Copy link

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_openshift_ansible/11/) (Base Commit: 5fe1609)

@openshift-bot
Copy link

success: "aos-ci-jenkins/OS_3.6_NOT_containerized, aos-ci-jenkins/OS_3.6_NOT_containerized_e2e_tests" for daebc9f (logs)

@rhcarvalho
Copy link
Contributor

Flake openshift/origin#13731.

[merge] again

@openshift-bot
Copy link

Evaluated for openshift ansible merge up to daebc9f

@openshift-bot
Copy link

openshift-bot commented Apr 12, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_openshift_ansible/207/) (Base Commit: 5ffbb64)

@openshift-bot openshift-bot merged commit 9ba1fde into openshift:master Apr 12, 2017
@juanvallejo juanvallejo deleted the jvallejo/skip-yum-update-check-on-fedora branch April 12, 2017 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants