Bug 2071418
| Summary: | TuneD exits on duplicate config lines (new ConfigParser implementation) | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Jiří Mencák <jmencak> |
| Component: | tuned | Assignee: | Jaroslav Škarvada <jskarvad> |
| Status: | CLOSED ERRATA | QA Contact: | Robin Hack <rhack> |
| Severity: | high | Docs Contact: | |
| Priority: | high | ||
| Version: | 8.6 | CC: | jeder, jskarvad |
| Target Milestone: | rc | Keywords: | AutoVerified, Patch, TestCaseNeeded, TestCaseProvided, Triaged, Upstream |
| Target Release: | --- | Flags: | pm-rhel:
mirror+
|
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | tuned-2.20.0-0.1.rc1.el8 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2023-05-16 09:12:54 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Deadline: | 2023-02-27 | ||
Upstream PR: https://github.com/redhat-performance/tuned/pull/483 With the new parser and the above fix it doesn't traceback, but the profile is not loaded. Jiri do you need the profile to be loaded e.g. with the warning. (In reply to Jaroslav Škarvada from comment #2) > Jiri do you need the profile to be loaded e.g. with the warning. Or are you OK with the current fix? (In reply to Jaroslav Škarvada from comment #3) > (In reply to Jaroslav Škarvada from comment #2) > > Jiri do you need the profile to be loaded e.g. with the warning. > > Or are you OK with the current fix? This will probably require more customization of the parser, i.e it may not be worth the effort. (In reply to Jaroslav Škarvada from comment #2) > Jiri do you need the profile to be loaded e.g. with the warning. That would be the ideal solution. Profile applied with the warning. I do not believe it ever worked like this, but really, it should. (In reply to Jiří Mencák from comment #14) > (In reply to Jaroslav Škarvada from comment #2) > > Jiri do you need the profile to be loaded e.g. with the warning. > > That would be the ideal solution. Profile applied with the warning. > I do not believe it ever worked like this, but really, it should. We probably want the last directive to take effect, i.e. [selinux] avc_cache_threshold=4096 avc_cache_threshold=8192 avc_cache_threshold should be 8192, but a warning issued when applying it. Well, IMHO it could work this way with python-2.7 (I haven't tried), thus this could be a regression that came with python-3.2. The following workaround should bring the old behavior back:
--- a/tuned/profiles/loader.py
+++ b/tuned/profiles/loader.py
@@ -96,7 +96,7 @@ class Loader(object):
def _load_config_data(self, file_name):
try:
- config_obj = ConfigParser(delimiters=('='), inline_comment_prefixes=('#'))
+ config_obj = ConfigParser(delimiters=('='), inline_comment_prefixes=('#'), strict=False)
config_obj.optionxform=str
with open(file_name) as f:
config_obj.read_file(f, file_name)
I will open PR for review.
(In reply to Jaroslav Škarvada from comment #16) > Well, IMHO it could work this way with python-2.7 (I haven't tried), thus > this could be a regression that came with python-3.2. The following > workaround should bring the old behavior back: > --- a/tuned/profiles/loader.py > +++ b/tuned/profiles/loader.py > @@ -96,7 +96,7 @@ class Loader(object): > > def _load_config_data(self, file_name): > try: > - config_obj = ConfigParser(delimiters=('='), > inline_comment_prefixes=('#')) > + config_obj = ConfigParser(delimiters=('='), > inline_comment_prefixes=('#'), strict=False) > config_obj.optionxform=str > with open(file_name) as f: > config_obj.read_file(f, file_name) > > I will open PR for review. https://github.com/redhat-performance/tuned/pull/484 (In reply to Jaroslav Škarvada from comment #16) > Well, IMHO it could work this way with python-2.7 (I haven't tried), thus > this could be a regression that came with python-3.2. The following > workaround should bring the old behavior back: More precisely I believe (untested by me): - it works with the old parser and python-2.7 - it works with the new parser and python > 3.0 and python < 3.2 - it doesn't work with the new parser and python-2.7 - it doesn't work with the new parser and python >= 3.2, because python switched to the strict=True by default in python-3.2 Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (tuned bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2023:3062 |
Description of problem: In the past, duplicate configuration lines in tuned.conf files were treated as (non-fatal) errors and didn't produce traceback. Exitting 1 on invalid configuration file will cause issues both on RHEL/systemd and in OCP continuously trying to restart the tuned process. The latest FDP TuneD version tuned-2.18.0-1.1.20220317gite1045f2d.el8fdp.noarch.rpm exits 1 with the following configuration file: [main] summary=PoC [selinux] avc_cache_threshold=8192 avc_cache_threshold=8192 $ tuned --no-dbus Version-Release number of selected component (if applicable): perf148a:bz # tuned --no-dbus 2022-04-03 19:54:30,032 INFO tuned.daemon.application: TuneD: 2.18.0, kernel: 4.18.0-348.2.1.el8_5.x86_64 2022-04-03 19:54:30,033 INFO tuned.daemon.application: dynamic tuning is globally disabled 2022-04-03 19:54:30,038 INFO tuned.daemon.daemon: using sleep interval of 1 second(s) 2022-04-03 19:54:30,039 INFO tuned.profiles.loader: loading profile: bz Traceback (most recent call last): File "/usr/sbin/tuned", line 68, in <module> app = tuned.daemon.Application(args.profile, config) File "/usr/lib/python3.6/site-packages/tuned/daemon/application.py", line 55, in __init__ self._daemon = daemon.Daemon(unit_manager, profile_loader, profile_name, self.config, self) File "/usr/lib/python3.6/site-packages/tuned/daemon/daemon.py", line 49, in __init__ self._init_profile(profile_names) File "/usr/lib/python3.6/site-packages/tuned/daemon/daemon.py", line 90, in _init_profile self.set_all_profiles(profile_names, manual, post_loaded_profile) File "/usr/lib/python3.6/site-packages/tuned/daemon/daemon.py", line 145, in set_all_profiles self._load_profiles(active_profiles, manual) File "/usr/lib/python3.6/site-packages/tuned/daemon/daemon.py", line 107, in _load_profiles self._profile = self._profile_loader.load(profile_list) File "/usr/lib/python3.6/site-packages/tuned/profiles/loader.py", line 52, in load self._load_profile(profile_names, profiles, processed_files) File "/usr/lib/python3.6/site-packages/tuned/profiles/loader.py", line 86, in _load_profile config = self._load_config_data(filename) File "/usr/lib/python3.6/site-packages/tuned/profiles/loader.py", line 102, in _load_config_data config_obj.read_file(f, file_name) File "/usr/lib64/python3.6/configparser.py", line 718, in read_file self._read(f, source) File "/usr/lib64/python3.6/configparser.py", line 1092, in _read fpname, lineno) configparser.DuplicateOptionError: While reading from '/etc/tuned/bz/tuned.conf' [line 6]: option 'avc_cache_threshold' in section 'selinux' already exists How reproducible: Always Expected results: TuneD doesn't exit 1 on invalid configuration file.