RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2071418 - TuneD exits on duplicate config lines (new ConfigParser implementation)
Summary: TuneD exits on duplicate config lines (new ConfigParser implementation)
Keywords:
Status: CLOSED ERRATA
Alias: None
Deadline: 2023-02-27
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: tuned
Version: 8.6
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Jaroslav Škarvada
QA Contact: Robin Hack
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-04-03 18:05 UTC by Jiří Mencák
Modified: 2023-05-16 11:23 UTC (History)
2 users (show)

Fixed In Version: tuned-2.20.0-0.1.rc1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-16 09:12:54 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-117693 0 None None None 2022-04-03 18:11:50 UTC
Red Hat Product Errata RHBA-2023:3062 0 None None None 2023-05-16 09:13:00 UTC

Description Jiří Mencák 2022-04-03 18:05:13 UTC
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.

Comment 1 Jaroslav Škarvada 2022-11-28 13:40:48 UTC
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.

Comment 2 Jaroslav Škarvada 2022-11-28 13:41:55 UTC
Jiri do you need the profile to be loaded e.g. with the warning.

Comment 3 Jaroslav Škarvada 2022-11-28 13:42:33 UTC
(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?

Comment 4 Jaroslav Škarvada 2022-11-28 13:49:14 UTC
(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.

Comment 14 Jiří Mencák 2022-11-28 15:13:16 UTC
(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.

Comment 15 Jiří Mencák 2022-11-28 15:15:22 UTC
(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.

Comment 16 Jaroslav Škarvada 2022-11-28 15:24:44 UTC
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.

Comment 17 Jaroslav Škarvada 2022-11-28 15:47:14 UTC
(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

Comment 18 Jaroslav Škarvada 2022-11-28 15:59:17 UTC
(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

Comment 32 errata-xmlrpc 2023-05-16 09:12:54 UTC
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


Note You need to log in before you can comment on or make changes to this bug.