redhat-performance / tuned

Tuning Profile Delivery Mechanism for Linux
GNU General Public License v2.0
751 stars 171 forks source link

Fix running the CPU plugin with procfs from pypi #607

Open superm1 opened 4 months ago

superm1 commented 4 months ago

Using the latest procfs from pypi fails because it doesn't have a cpuinfo() member. Catch these exceptions and try to more gracefully handle them instead of a traceback from the daemon.

Link: https://pypi.org/project/procfs/

superm1 commented 4 months ago

BTW - this was on Ubuntu 22.04, I ran into this problem. I didn't have anything natively installed for procfs which is why I went to pypi.

If I sudo apt install python3-linux-procfs that version seems to work.

$ apt policy python3-linux-procfs
python3-linux-procfs:
  Installed: 0.6.3-1.1build1
  Candidate: 0.6.3-1.1build1
  Version table:
 *** 0.6.3-1.1build1 500
        500 http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        100 /var/lib/dpkg/status

But nonetheless it's better to be defensive against this problem IMO.

evgeni commented 4 months ago

FWIW, the tuned package in Debian (and Ubuntu) depends on python3-linux-procfs. I don't think procfs on pypi is related to the one in that package at all.

superm1 commented 4 months ago

Right I was working from source is why I hit this.

It shares the same namespace tho. And even if I install the right one in Ubuntu if this one from pypi is installed it takes preference and causes the breakage due to search path priority.

yarda commented 3 months ago

I think if we want to handle this, we should detect the wrong library at the import and log error or warning that it's incompatible library.