Bug 1739418

Summary: Regression: Unhandled exception in tuned 2.11 when using '=>' for a sysctl
Product: Red Hat Enterprise Linux 7 Reporter: Jiří Mencák <jmencak>
Component: tunedAssignee: Jaroslav Škarvada <jskarvad>
Status: CLOSED ERRATA QA Contact: Robin Hack <rhack>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 7.7CC: fkrska, jeder, jskarvad, olysonek, psklenar, rgregory, rhack, rhowe, rsandu, thozza
Target Milestone: rcKeywords: Patch, Regression, TestCaseProvided, Upstream, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tuned-2.11.0-7.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1739563 1752415 (view as bug list) Environment:
Last Closed: 2020-03-31 19:12:11 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: 1739563, 1752415    

Description Jiří Mencák 2019-08-09 09:26:37 UTC
Description of problem:
When running tuned 2.11, sysctl settings with '=>' functionality cause unhandled exceptions.

Version-Release number of selected component (if applicable):
tuned-2.11.0-5.el7.noarch

How reproducible:
Always when running tuned in one-shot mode

Steps to Reproduce:
1. mkdir -p /etc/tuned/pidmax
2. 
[root@b7 pidmax]# cat > /etc/tuned/pidmax/tuned.conf <<EOF
> [main]
> summary=PoC
> 
> [sysctl]
> kernel.pid_max=>131072
> EOF

3. Optionally switch tuned config to one-shot mode
sed -i 's|^daemon.*|daemon = 0|' /etc/tuned/tuned-main.conf 

4. Shut down the tuned daemon if running

5. Run tuned (e.g. tuned --no-dbus --debug)

Actual results:
[root@b7 pidmax]# rpm -q tuned
tuned-2.11.0-5.el7.noarch
[root@b7 pidmax]# tuned --no-dbus --debug
2019-08-09 05:05:13,253 INFO     tuned.daemon.application: dynamic tuning is globally disabled
2019-08-09 05:05:13,257 DEBUG    tuned.daemon.daemon: initializing daemon
2019-08-09 05:05:13,257 INFO     tuned.daemon.daemon: using sleep interval of 1 second(s)
2019-08-09 05:05:13,257 INFO     tuned.profiles.loader: loading profile: pidmax
2019-08-09 05:05:13,258 WARNING  tuned.daemon.application: Using one shot no deamon mode, most of the functionality will be not available, it can be changed in global config
2019-08-09 05:05:13,258 INFO     tuned.daemon.controller: starting controller
2019-08-09 05:05:13,258 INFO     tuned.daemon.daemon: starting tuning
2019-08-09 05:05:13,259 DEBUG    tuned.plugins.repository: creating plugin sysctl
2019-08-09 05:05:13,259 DEBUG    tuned.utils.plugin_loader: loading module tuned.plugins.plugin_sysctl
2019-08-09 05:05:13,259 DEBUG    tuned.units.manager: creating 'sysctl' (sysctl)
2019-08-09 05:05:13,259 DEBUG    tuned.plugins.base: initializing instance sysctl (sysctl)
2019-08-09 05:05:13,259 DEBUG    tuned.hardware.inventory: starting monitor observer
2019-08-09 05:05:13,260 INFO     tuned.daemon.controller: terminating controller
2019-08-09 05:05:13,260 INFO     tuned.daemon.daemon: stopping tuning
2019-08-09 05:05:13,260 DEBUG    tuned.plugins.plugin_sysctl: Value of sysctl parameter 'kernel.pid_max' is '131072'
2019-08-09 05:05:13,260 DEBUG    tuned.plugins.plugin_sysctl: Setting sysctl parameter 'kernel.pid_max' to 'None'
2019-08-09 05:05:13,261 ERROR    tuned.units.manager: BUG: Unhandled exception in start_tuning: expected a character buffer object
2019-08-09 05:05:13,261 ERROR    tuned.units.manager: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/tuned/units/manager.py", line 88, in _try_call
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/tuned/plugins/instance/instance.py", line 78, in apply_tuning
    self._plugin.instance_apply_tuning(self)
  File "/usr/lib/python2.7/site-packages/tuned/plugins/base.py", line 261, in instance_apply_tuning
    self._instance_apply_static(instance)
  File "/usr/lib/python2.7/site-packages/tuned/plugins/plugin_sysctl.py", line 62, in _instance_apply_static
    _write_sysctl(option, new_value)
  File "/usr/lib/python2.7/site-packages/tuned/plugins/plugin_sysctl.py", line 174, in _write_sysctl
    f.write(value)
TypeError: expected a character buffer object

2019-08-09 05:05:13,261 INFO     tuned.daemon.daemon: static tuning from profile 'pidmax' applied
2019-08-09 05:05:13,261 DEBUG    tuned.utils.commands: Executing ['systemctl', 'is-system-running'].
2019-08-09 05:05:13,265 DEBUG    tuned.utils.commands: Executing ['systemctl', 'list-jobs'].
2019-08-09 05:05:13,269 INFO     tuned.daemon.daemon: terminating Tuned in one-shot mode
2019-08-09 05:05:13,270 DEBUG    tuned.units.manager: destroying instance sysctl
2019-08-09 05:05:13,270 DEBUG    tuned.units.manager: cleaning plugin 'sysctl'
[root@b7 pidmax]# echo $? # Ideally, this should also be non-zero when failing
0

Expected results:
No unhandled exception and the sysctl applied as expected.

Additional info:
Associated OCP 4.1 bugzilla
https://bugzilla.redhat.com/show_bug.cgi?id=1739322

Comment 3 Jaroslav Škarvada 2019-08-09 09:47:03 UTC
Fixed by the following upstream commit:
https://github.com/redhat-performance/tuned/commit/a8f2a8306e1bac6cfc739e6753d381bf509c995e

Comment 10 Ryan Howe 2019-09-05 20:18:05 UTC
*** Bug 1749411 has been marked as a duplicate of this bug. ***

Comment 13 errata-xmlrpc 2020-03-31 19:12:11 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, 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-2020:1008