From b23c2493e96fa964f64d3fd151ce8226a441b078 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Thu, 22 Feb 2024 15:11:33 -0600 Subject: [PATCH] Fix running the CPU plugin with procfs from pypi 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/ --- tuned/plugins/plugin_cpu.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tuned/plugins/plugin_cpu.py b/tuned/plugins/plugin_cpu.py index 906070d7..17f11540 100644 --- a/tuned/plugins/plugin_cpu.py +++ b/tuned/plugins/plugin_cpu.py @@ -246,7 +246,11 @@ def _check_arch(self): # Possible other x86 vendors (from arch/x86/kernel/cpu/*): # "CentaurHauls", "CyrixInstead", "Geode by NSC", "HygonGenuine", "GenuineTMx86", # "TransmetaCPU", "UMC UMC UMC" - cpu = procfs.cpuinfo() + try: + cpu = procfs.cpuinfo() + except AttributeError as error: + log.error("Unable to detect CPU: %s" % error) + return vendor = cpu.tags.get("vendor_id") if vendor == "GenuineIntel": self._is_intel = True @@ -295,7 +299,11 @@ def _check_amd_pstate(self): def _get_cpuinfo_flags(self): if self._flags is None: - self._flags = procfs.cpuinfo().tags.get("flags", []) + try: + self._flags = procfs.cpuinfo().tags.get("flags", []) + except AttributeError as error: + log.error("failed to read flags: %s" % error) + return [] return self._flags def _is_cpu_online(self, device):