Bug 1461279

Summary: Heredity of cmdline works wrong when using 'replace=false'
Product: Red Hat Enterprise Linux 7 Reporter: Tereza Cerna <tcerna>
Component: tunedAssignee: Jaroslav Škarvada <jskarvad>
Status: CLOSED ERRATA QA Contact: Tereza Cerna <tcerna>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: jeder, jskarvad, olysonek, psklenar
Target Milestone: rcKeywords: Patch, Upstream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tuned-2.9.0-0.1.rc1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 16:04:16 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: 1465887, 1467576, 1485946    

Description Tereza Cerna 2017-06-14 06:29:46 UTC
Description of problem:
=======================
Bootloader plugin for heredity of cmdline with addition/overwrite doesn't work as expected. 

When user uses rule 'replace=false' in child profile, all parents parameters were inherited to child. Then user wants to remove some rule from parent profile with using '=-', but this rules are still there and it should not be there. See reproducer and results.

Version-Release number of selected component:
=============================================
tuned-2.8.0-4.el7.noarch

How reproducible:
=================
always

Steps to Reproduce:
===================
1. Create a parent profile:
   # cat /usr/lib/tuned/parent-profile/tuned.conf 
   [bootloader]
   cmdline=quiet noexec=on intel_pstate=disable

2. Create a child profile:
   # cat /usr/lib/tuned/child-profile/tuned.conf 
   [main]
   include=parent-profile

   [bootloader]
   replace=false
   cmdline1=+nosoftlockup
   cmdline2=-quiet intel_pstate=disable
   cmdline3=nmi_watchdog=1

3. Activate child profile:
   # tuned-adm profile child-profile

Actual results:
===============
# grep 'set tuned_params=' /boot/grub2/grub.cfg
set tuned_params="quiet noexec=on intel_pstate=disable nosoftlockup nmi_watchdog=1"

Expected results:
=================
# grep 'set tuned_params=' /boot/grub2/grub.cfg
set tuned_params="noexec=on nosoftlockup nmi_watchdog=1"

Additional info:
================
Founded in automated test case /CoreOS/tuned/Regression/add-bootloader-plugin-for-heredity-of-cmdline-options

Comment 2 Tereza Cerna 2017-06-14 06:36:33 UTC
Info for QA:
This bug was found in automated test case /CoreOS/tuned/Regression/add-bootloader-plugin-for-heredity-of-cmdline-options in phase 'TEST 3'

Comment 3 Jaroslav Škarvada 2017-06-14 14:07:19 UTC
I am currently not sure whether it's actually bug. The line "cmdline2=-quiet intel_pstate=disable" tries to match and remove string "quiet intel_pstate=disable" which is not there, the following will do the trick:

# cat /usr/lib/tuned/child-profile/tuned.conf 
[main]
include=parent-profile

[bootloader]
replace=false
cmdline1=+nosoftlockup
cmdline2=-quiet
cmdline2.5=-intel_pstate=disable
cmdline3=nmi_watchdog=1

I.e. it will try to remove strings "quiet" and "intel_pstate=disable". Of course we could learn the plugin to automatically split it which will be probably more user friendly.

Comment 4 Jaroslav Škarvada 2017-06-14 14:43:10 UTC
RFE implemented upstream:
https://github.com/redhat-performance/tuned/commit/f068a031a820ae48426cb8c99e38a8873988a570

Comment 6 Ondřej Lysoněk 2017-07-04 09:04:01 UTC
Actually it's not a bug, it's meant to be a feature :). The reason I implemented it this way is to account for the following:

# cat /usr/lib/tuned/parent-profile/tuned.conf 
[bootloader]
cmdline=some_option 1 other_option 1

# cat /usr/lib/tuned/child-profile/tuned.conf 
[main]
include=parent-profile

[bootloader]
cmdline1=-other_option 1


Where the '1' belongs to the options 'some_option' and 'other_option'. After applying the child profile with the new implementation, you would get 'cmdline=some_option', which is not what you want. I'm not sure if such options exist in the kernel though.

Comment 7 Jaroslav Škarvada 2017-07-04 09:39:11 UTC
(In reply to Ondřej Lysoněk from comment #6)
> Actually it's not a bug, it's meant to be a feature :). The reason I
> implemented it this way is to account for the following:
> 
> # cat /usr/lib/tuned/parent-profile/tuned.conf 
> [bootloader]
> cmdline=some_option 1 other_option 1
> 
> # cat /usr/lib/tuned/child-profile/tuned.conf 
> [main]
> include=parent-profile
> 
> [bootloader]
> cmdline1=-other_option 1
> 
> 
> Where the '1' belongs to the options 'some_option' and 'other_option'. After
> applying the child profile with the new implementation, you would get
> 'cmdline=some_option', which is not what you want. I'm not sure if such
> options exist in the kernel though.

I thought it's not a bug. If I am not mistaken it should be safe to split the cmdline by spaces (and also more user friendly). IMHO the cmdline is free text, interpreted by dracut, it's scripts, kernel modules (or builtins) and AFAIK space is taken as a separator. At the moment I am not aware of anything interpreting it different way, but of course such thing can exists. To be 100% safe we could add modifier for not doing the auto-split.

Comment 8 Fedora Update System 2017-10-13 14:20:42 UTC
tuned-2.9.0-0.1.rc1.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-d9c6b990df

Comment 10 Fedora Update System 2017-10-13 22:25:08 UTC
tuned-2.9.0-0.1.rc1.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-d9c6b990df

Comment 11 Fedora Update System 2017-10-13 23:24:56 UTC
tuned-2.9.0-0.1.rc1.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-5f0849d207

Comment 12 Fedora Update System 2017-10-29 21:06:55 UTC
tuned-2.9.0-1.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2017-0e45ce4685

Comment 13 Fedora Update System 2017-10-29 21:13:02 UTC
tuned-2.9.0-1.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-c30e9bd1ea

Comment 14 Tereza Cerna 2018-01-05 11:35:26 UTC
============================
Verified in:
    tuned-2.9.0-1.el7.noarch
PASS
============================

:: [   LOG    ] :: ===== Apply child profile =====
:: [   PASS   ] :: Command 'tuned-adm profile test3-child-profile' (Expected 0, got 0)
:: [   PASS   ] :: Command 'grep ERROR /var/log/tuned/tuned.log' (Expected 1, got 1)
:: [   PASS   ] :: Command 'grep 'set tuned_params=' /boot/grub2/grub.cfg > output' (Expected 0, got 0)
:: [   LOG    ] :: There should be: noexec=on nosoftlockup nmi_watchdog=1
:: [   PASS   ] :: Command 'grep noexec=on output' (Expected 0, got 0)
:: [   PASS   ] :: Command 'grep nosoftlockup output' (Expected 0, got 0)
:: [   PASS   ] :: Command 'grep nmi_watchdog=1 output' (Expected 0, got 0)
:: [   LOG    ] :: There shouldn't be: intel_pstate=disable quiet
:: [   PASS   ] :: Command 'grep intel_pstate=disable output' (Expected 1, got 1)
:: [   PASS   ] :: Command 'grep quiet output' (Expected 1, got 1)

============================
Reproduced in:
    tuned-2.8.0-5.el7.noarch
FAIL
============================

:: [   LOG    ] :: ===== Apply child profile =====
:: [   PASS   ] :: Command 'tuned-adm profile test3-child-profile' (Expected 0, got 0)
:: [   PASS   ] :: Command 'grep ERROR /var/log/tuned/tuned.log' (Expected 1, got 1)
:: [   PASS   ] :: Command 'grep 'set tuned_params=' /boot/grub2/grub.cfg > output' (Expected 0, got 0)
:: [   LOG    ] :: There should be: noexec=on nosoftlockup nmi_watchdog=1
:: [   PASS   ] :: Command 'grep noexec=on output' (Expected 0, got 0)
:: [   PASS   ] :: Command 'grep nosoftlockup output' (Expected 0, got 0)
:: [   PASS   ] :: Command 'grep nmi_watchdog=1 output' (Expected 0, got 0)
:: [   LOG    ] :: There shouldn't be: intel_pstate=disable quiet
:: [   FAIL   ] :: Command 'grep intel_pstate=disable output' (Expected 1, got 0)
:: [   FAIL   ] :: Command 'grep quiet output' (Expected 1, got 0)

Comment 17 errata-xmlrpc 2018-04-10 16:04:16 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-2018:0879