Skip to content

Import dnf only if importing yum fails - #5299

Merged
sdodson merged 2 commits into
openshift:masterfrom
jhadvig:dnf_issue
Sep 6, 2017
Merged

sdodson merged 2 commits into
openshift:masterfrom
jhadvig:dnf_issue

Conversation

@jhadvig

@jhadvig jhadvig commented Sep 5, 2017 •

Copy link
Copy Markdown
Member

We should try to import dnf only if importing yum fails. Part of the issue also was that importing dnf didn't failed even though dnf wasn't installed on the system.

Change is tested on this job

@mfojtik @sdodson @stevekuznetsov @jupierce fyi

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 5, 2017
@mfojtik

mfojtik commented Sep 5, 2017 •

Copy link
Copy Markdown
Contributor

This is basically saying that "if we have yum" use yum and don't try to import dnf. In Fedora I guess you will have both installed, but yum will be just yelling at you to use dnf instead.

Problem is that you can have dnf python module installed but not the '/usr/bin/dnf' binary, which is the case we trying to solve here (I guess). In that case, we succeed importing yum, then we succeed importing dnf and set the package manager to dnf. Afterwards when ansible decide which pkg manager to use, it picks dnf, which is not installed as binary and fail.

So to fix this:

  1. import yum
  2. if failed, import dnf
  3. if succeed check if /usr/bin/dnf is present in system
  4. if failed, fallback to yum

just my .40 cents :)

@openshift-ci-robot openshift-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 5, 2017
@jhadvig

jhadvig commented Sep 5, 2017

Copy link
Copy Markdown
Member Author

PR updated based on discussion with @mfojtik && @soltysh

@soltysh soltysh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm

@rhcarvalho rhcarvalho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the symptom this PR is trying to address?

I followed the original description to look at https://storage.googleapis.com/origin-ci-test/pr-logs/pull/16136/test_pull_request_origin_extended_conformance_install_update/5392/artifacts/junit_01.xml, and all I see is a failure that misses an important part of the message:

...
<testcase name="[localhost] openshift_health_check" time="336.609850">
<failure message="One or more checks failed" type="failure"/>
</testcase>
...

Is it missing the list of failed checks and reason.
Where could we add more context to that message? (the per-check information is accessible from the checks key of the result hash)

try:
# We need to check whether the dnf binary is installed, since the
# import of dnf module won't fail even if the dnf binary is missing
subprocess.call(["dnf"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Both ansible/modules/packaging/os/yum.py and ansible/modules/packaging/os/dnf.py use the Python libraries to interact with the package manager, and not their command line binaries.

@rhcarvalho

Copy link
Copy Markdown
Contributor

@sosiouxme FYI

@mfojtik

mfojtik commented Sep 5, 2017

Copy link
Copy Markdown
Contributor

What is the symptom this PR is trying to address?

The consequence of this seems to be that we are not able to check whether docker package is installed or not (it is installed but we can't find it). @jhadvig made a test job with this fix and it seems to fix this problem. This is currently blocking all merges in origin, we can make a better solution later, but we need to unblock the merge for now.

@mfojtik mfojtik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@deads2k

deads2k commented Sep 5, 2017

Copy link
Copy Markdown
Contributor

looks like you failed linting.

@jhadvig

jhadvig commented Sep 5, 2017

Copy link
Copy Markdown
Member Author

@deads2k updated

@deads2k

deads2k commented Sep 5, 2017

Copy link
Copy Markdown
Contributor

[test] maybe?

@smarterclayton

Copy link
Copy Markdown
Contributor

aos-ci-test

@openshift-bot

Copy link
Copy Markdown

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

@sdodson

sdodson commented Sep 5, 2017

Copy link
Copy Markdown
Member

yum mirror flake
[test]

@openshift-bot

Copy link
Copy Markdown

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

@sdodson

sdodson commented Sep 5, 2017

Copy link
Copy Markdown
Member

[test]

@sdodson

sdodson commented Sep 5, 2017

Copy link
Copy Markdown
Member

aos-ci-test

@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 5, 2017
@jhadvig

jhadvig commented Sep 5, 2017

Copy link
Copy Markdown
Member Author

@stevekuznetsov PR updated based on our discussion. Now we shall use dnf only if importing yum will fail.

@jhadvig

jhadvig commented Sep 5, 2017

Copy link
Copy Markdown
Member Author

[test]

@sosiouxme

Copy link
Copy Markdown
Member

Whether dnf or yum imports is probably not the best test of which is in use. Probably worthwhile asking "what would ansible do?" but we actually don't have to... ansible tells us with the ansible_pkg_mgr fact. We could just attempt to import both dnf and yum, then pass that fact into the module so it knows which to use.

Though I'm not opposed to just merging whatever unblocks the queue for the short term.

except ImportError as err:
DNF_IMPORT_EXCEPTION = err

# Import and use dnf only if yum is missing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, this could go for now, but long term we might want to do the same as the package action plugin that dispatches to the yum or dnf module, and use the ansible_pkg_mgr fact:

https://github.com/ansible/ansible/blob/1b8f4558f76fea0d1533ca6581815429c6f92ee8/lib/ansible/plugins/action/package.py#L55

Since modules don't have access to any of Ansible's internals, we'd pass in as an arg either yum or dnf from the check in package_availability.py.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I did not mean to leave the conditional in. Should try to import both regardless, and use the one indicated by ansible_pkg_mgr.

@sdodson

sdodson commented Sep 5, 2017

Copy link
Copy Markdown
Member

[test]

@openshift-bot

Copy link
Copy Markdown

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

@openshift-bot

Copy link
Copy Markdown

success: "aos-ci-jenkins/OS_3.6_containerized, aos-ci-jenkins/OS_3.6_containerized_e2e_tests" for 0119b4a (logs)

@sdodson

sdodson commented Sep 5, 2017 •

Copy link
Copy Markdown
Member

This is a proposed fix for openshift/origin#16143 for which we don't yet understand root cause.

@sdodson

sdodson commented Sep 5, 2017

Copy link
Copy Markdown
Member

[test]

@openshift-bot

Copy link
Copy Markdown

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

@openshift-bot

Copy link
Copy Markdown

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

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 5, 2017
@sosiouxme

Copy link
Copy Markdown
Member

I humbly submit an added commit to hopefully bring a little more sanity to this check.

@sosiouxme

Copy link
Copy Markdown
Member

aos-ci-test

rhcarvalho
rhcarvalho previously approved these changes Sep 5, 2017

@rhcarvalho rhcarvalho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@openshift-bot

Copy link
Copy Markdown

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

@openshift-bot

Copy link
Copy Markdown

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

@sdodson

sdodson commented Sep 6, 2017

Copy link
Copy Markdown
Member

[test]

Tweaks to the logic around using yum vs dnf; now uses ansible_pkg_mgr to
determine which is in effect for a host.
Also, extended the yum logic to check installed packages in addition to
available packages in the aos_version module so that disconnected
installs and others with weird repo configs need not disable the
package_version check.
@sosiouxme

Copy link
Copy Markdown
Member

aos-ci-test

@openshift-bot

Copy link
Copy Markdown

Evaluated for openshift ansible test up to 8e51499

@openshift-bot

Copy link
Copy Markdown

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_openshift_ansible/609/) (Base Commit: 89c5814) (PR Branch Commit: 8e51499)

@sosiouxme

sosiouxme commented Sep 6, 2017 via email

Copy link
Copy Markdown
Member

@sdodson

sdodson commented Sep 6, 2017 via email

Copy link
Copy Markdown
Member

@openshift-bot

Copy link
Copy Markdown

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

@openshift-bot

Copy link
Copy Markdown

success: "aos-ci-jenkins/OS_3.6_containerized, aos-ci-jenkins/OS_3.6_containerized_e2e_tests" for 8e51499 (logs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants