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

dnf module errors with mitogen on Ansible 2.16.7+ #1143

Open
psvmcc opened this issue Oct 7, 2024 · 4 comments
Open

dnf module errors with mitogen on Ansible 2.16.7+ #1143

psvmcc opened this issue Oct 7, 2024 · 4 comments
Labels
affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome

Comments

@psvmcc
Copy link
Contributor

psvmcc commented Oct 7, 2024

I see errors on dnf tasks like:

PLAY [Common server configuration] *********************************************
Failed loading plugin "copr": module 'dnf' has no attribute 'cli'
Failed loading plugin "debuginfo-install": module 'dnf' has no attribute 'cli'
Failed loading plugin "copr": module 'dnf' has no attribute 'cli'
Failed loading plugin "debuginfo-install": module 'dnf' has no attribute 'cli'
Failed loading plugin "copr": module 'dnf' has no attribute 'cli'
Failed loading plugin "debuginfo-install": module 'dnf' has no attribute 'cli'
Failed loading plugin "copr": module 'dnf' has no attribute 'cli'

Task example:

- name: Setup rsync
  ansible.builtin.dnf:
    name:
      - rsync-daemon
    state: present

Output messages:

TASK [rsync : Setup rsync] ****************************************************
Failed loading plugin "debuginfo-install": module 'dnf' has no attribute 'cli'
ok: [hostname]

Without mitogen everything works well.

@psvmcc psvmcc added affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome labels Oct 7, 2024
@moreati moreati changed the title dnf module errors with mitogen on ansible starting from 2.6.17 dnf module errors with mitogen on Ansible 2.6.17+ Oct 9, 2024
@psvmcc
Copy link
Contributor Author

psvmcc commented Jan 21, 2025

@moreati maybe I can someone help with debug?

@psvmcc psvmcc changed the title dnf module errors with mitogen on Ansible 2.6.17+ dnf module errors with mitogen on Ansible 2.16.7+ Jan 21, 2025
@moreati
Copy link
Member

moreati commented Jan 28, 2025

Looks screwy, probably of Mitogen's doing.

My first guess is that Mitogen is confusing one of the fully qualified Python module names ansible.modules.dnf, ansible.builtin.dnf ... with the FQN dnf. So on the target sys.modules['dnf'] ends up containing the wrong module object.

Notes to self

@psvmcc
Copy link
Contributor Author

psvmcc commented Jan 28, 2025

Yesterday, I delved into this issue by adding debugging to the DNF libraries. I have several hosts, but the problem doesn’t occur on all of them.

To investigate further, I picked a couple of hosts and began comparing them. I checked everything under /etc, /usr, and /var related to Python and DNF. In terms of the filesystem and versioning, everything was identical across the two hosts.

When I enabled debugging, I noticed that DNF loads its plugins from /usr/lib/python3.9/site-packages/dnf-plugins/ in a different order on the two hosts. This caught my attention, as it seemed to be the root of the issue. Specifically, if a plugin that already imports dnf.cli was loaded first, the problem didn’t occur.

I compared the ctime and inode of the files, and the order was identical. Additionally, I found that the find utility also returned the files in a different order, which is likely due to some quirks in the ext4 journaling system.

Bad Host

# find /usr/lib/python3.9/site-packages/dnf-plugins/ -type f | head -n 3
/usr/lib/python3.9/site-packages/dnf-plugins/debuginfo-install.py
/usr/lib/python3.9/site-packages/dnf-plugins/repoclosure.py
/usr/lib/python3.9/site-packages/dnf-plugins/config_manager.py

Good Host

# find /usr/lib/python3.9/site-packages/dnf-plugins/ -type f | head -n 3
/usr/lib/python3.9/site-packages/dnf-plugins/ulninfo.py
/usr/lib/python3.9/site-packages/dnf-plugins/config_manager.py
/usr/lib/python3.9/site-packages/dnf-plugins/copr.py

This behavior came as a surprise to me. However, I still don’t understand how Mitogen influences this or why vanilla Ansible doesn’t encounter the same issue. Even with maximum verbosity (-vvvvv), I don’t see any errors when using vanilla Ansible.

@psvmcc psvmcc closed this as completed Jan 30, 2025
@moreati
Copy link
Member

moreati commented Jan 30, 2025

Reopening. I'm treating #1230 as a workaround, rather than a full fix.

@moreati moreati reopened this Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome
Projects
None yet
Development

No branches or pull requests

2 participants