Bug 2060138

Summary: Regression: TuneD fails to parse inline comments
Product: Red Hat Enterprise Linux 8 Reporter: Jiří Mencák <jmencak>
Component: tunedAssignee: Jaroslav Škarvada <jskarvad>
Status: CLOSED ERRATA QA Contact: Robin Hack <rhack>
Severity: high Docs Contact:
Priority: high    
Version: 8.6CC: jeder, jskarvad, jzerdik
Target Milestone: rcKeywords: AutoVerified, TestCaseNeeded, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tuned-2.19.0-0.1.rc1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-08 10:52:37 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:
Bug Depends On:    
Bug Blocks: 2059934    

Description Jiří Mencák 2022-03-02 19:34:22 UTC
Description of problem:
TuneD 2.18.0+ fails to parse inline comments properly.  An example of TuneD configuration file that poses issues for the parser:

[main]
summary=PoC

[cpu]
governor=performance                            # This is a comment

[service]
service.stalld=start,enable                     # This is a comment

[vm]
transparent_hugepages=never                     # This is a comment

[selinux]
avc_cache_threshold=8192                        # This is a comment

[net]
nf_conntrack_hashsize=131072                    # This is a comment

How reproducible:
Always


Actual results:
2022-03-02 14:29:27,274 INFO     tuned.daemon.application: TuneD: 2.18.0, kernel: 4.18.0-240.el8.x86_64
2022-03-02 14:29:27,274 INFO     tuned.daemon.application: dynamic tuning is globally disabled
2022-03-02 14:29:27,278 INFO     tuned.daemon.daemon: using sleep interval of 1 second(s)
2022-03-02 14:29:27,278 INFO     tuned.daemon.daemon: Running in automatic mode, checking what profile is recommended for your configuration.
2022-03-02 14:29:27,279 INFO     tuned.daemon.daemon: Using 'bz' profile
2022-03-02 14:29:27,280 INFO     tuned.profiles.loader: loading profile: bz
2022-03-02 14:29:27,281 INFO     tuned.daemon.controller: starting controller
2022-03-02 14:29:27,281 INFO     tuned.daemon.daemon: starting tuning
2022-03-02 14:29:27,303 INFO     tuned.plugins.base: instance cpu: assigning devices cpu0, cpu1
2022-03-02 14:29:27,307 INFO     tuned.plugins.plugin_cpu: We are running on an x86 GenuineIntel platform
2022-03-02 14:29:27,309 WARNING  tuned.plugins.plugin_cpu: your CPU doesn't support MSR_IA32_ENERGY_PERF_BIAS, ignoring CPU energy performance bias
2022-03-02 14:29:27,310 ERROR    tuned.plugins.plugin_service: service 'stalld': invalid service option: 'enable                        # This is a comment'
2022-03-02 14:29:27,311 INFO     tuned.plugins.base: instance net: assigning devices eth0
2022-03-02 14:29:27,382 WARNING  tuned.plugins.plugin_vm: Incorrect 'transparent_hugepages' value 'never                        # This is a comment'.
2022-03-02 14:29:27,383 ERROR    tuned.units.manager: BUG: Unhandled exception in start_tuning: invalid literal for int() with base 10: '8192\t\t\t# This is a comment'
2022-03-02 14:29:27,383 ERROR    tuned.units.manager: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/tuned/units/manager.py", line 119, in _try_call
    return f(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/instance/instance.py", line 78, in apply_tuning
    self._plugin.instance_apply_tuning(self)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/base.py", line 261, in instance_apply_tuning
    self._instance_apply_static(instance)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/base.py", line 317, in _instance_apply_static
    self._execute_all_non_device_commands(instance)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/base.py", line 433, in _execute_all_non_device_commands
    self._execute_non_device_command(instance, command, new_value)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/base.py", line 514, in _execute_non_device_command
    command["set"](new_value, sim = False)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/plugin_selinux.py", line 49, in _set_avc_cache_threshold
    threshold = int(value)
ValueError: invalid literal for int() with base 10: '8192\t\t\t# This is a comment'

2022-03-02 14:29:27,384 ERROR    tuned.utils.commands: Error when reading file '/sys/module/nf_conntrack/parameters/hashsize': '[Errno 2] No such file or directory: '/sys/module/nf_conntrack/parameters/hashsize''
2022-03-02 14:29:27,384 ERROR    tuned.units.manager: BUG: Unhandled exception in start_tuning: invalid literal for int() with base 10: '131072 \t\t\t# This is a comment'
2022-03-02 14:29:27,384 ERROR    tuned.units.manager: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/tuned/units/manager.py", line 119, in _try_call
    return f(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/instance/instance.py", line 78, in apply_tuning
    self._plugin.instance_apply_tuning(self)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/base.py", line 261, in instance_apply_tuning
    self._instance_apply_static(instance)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/base.py", line 317, in _instance_apply_static
    self._execute_all_non_device_commands(instance)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/base.py", line 433, in _execute_all_non_device_commands
    self._execute_non_device_command(instance, command, new_value)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/base.py", line 514, in _execute_non_device_command
    command["set"](new_value, sim = False)
  File "/usr/lib/python3.6/site-packages/tuned/plugins/plugin_net.py", line 275, in _set_nf_conntrack_hashsize
    hashsize = int(value)
ValueError: invalid literal for int() with base 10: '131072 \t\t\t# This is a comment'


Expected results:
TuneD config file properly parsed with inline comments.


Additional info:
https://github.com/redhat-performance/tuned/pull/380

Comment 1 Jiří Mencák 2022-03-06 13:00:12 UTC
Linking upstream issue: https://github.com/redhat-performance/tuned/issues/378

The upstream issue (and this BZ) seems to be fixed by https://github.com/redhat-performance/tuned/pull/380
I've tested the PR on the config in https://bugzilla.redhat.com/show_bug.cgi?id=2060138#c0 and
all inline comments were parsed correctly.

Comment 2 Jaroslav Škarvada 2022-03-17 09:59:38 UTC
The fix is already merged upstream. We will try to target RHEL-8.7. The fix will be also included in FDP, it's tracked by bug 2064605.

Comment 10 errata-xmlrpc 2022-11-08 10:52:37 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-2022:7747