diff --git a/tuned/utils/profile_recommender.py b/tuned/utils/profile_recommender.py index bbd0a1f..d544d34 100644 --- a/tuned/utils/profile_recommender.py +++ b/tuned/utils/profile_recommender.py @@ -56,6 +56,7 @@ class ProfileRecommender: def process_config(self, fname, has_root=True): matching_profile = None + syspurpose_error_logged = False try: if not os.path.isfile(fname): return None @@ -97,11 +98,11 @@ class ProfileRecommender: if not re.match(value, chassis_type, re.IGNORECASE): match = False elif option == "syspurpose_role": + role = "" if have_syspurpose: s = syspurpose.files.SyspurposeStore( syspurpose.files.USER_SYSPURPOSE, raise_on_error = True) - role = "" try: s.read_file() role = s.contents["role"] @@ -109,11 +110,13 @@ class ProfileRecommender: if hasattr(e, "errno") and e.errno != errno.ENOENT: log.error("Failed to load the syspurpose\ file: %s" % e) - if re.match(value, role, re.IGNORECASE) is None: - match = False else: - log.error("Failed to process 'syspurpose_role' in '%s'\ - , the syspurpose module is not available" % fname) + if not syspurpose_error_logged: + log.error("Failed to process 'syspurpose_role' in '%s'\ + , the syspurpose module is not available" % fname) + syspurpose_error_logged = True + if re.match(value, role, re.IGNORECASE) is None: + match = False if match: # remove the ",.*" suffix