Bug 1036049

Summary: [tuned] SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf" should be reversed
Product: Red Hat Enterprise Linux 6 Reporter: Jiri Belka <jbelka>
Component: tunedAssignee: Jaroslav Škarvada <jskarvad>
Status: CLOSED ERRATA QA Contact: Tereza Cerna <tcerna>
Severity: high Docs Contact:
Priority: high    
Version: 6.6CC: alonbl, bblaskov, didi, iheim, jbelka, jeder, jentrena, jskarvad, mnavrati, oschreib, ovasik, pep, psklenar, rvokal, sbonazzo, tcerna
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: tuned-0.2.19-15.el6 Doc Type: Bug Fix
Doc Text:
On Red Hat Enterprise Linux 6, the /etc/sysctl.conf file is the default configuration file for the sysctl tool settings and overrides can be specified in the /etc/sysctl.d/ directory. The tuned service previously handled the settings the opposite way, which is common in certain distributions. Consequently, the configuration specified in /etc/sysctl.d/ could be overridden by /etc/sysctl.conf. The way tuned handles /etc/sysctl.conf and /etc/sysctl.d/ has been reversed to match the Red Hat Enterprise Linux 6 logic. As a result, /etc/sysctl.conf is now processed first and can be overridden by settings in /etc/sysctl.d/.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-22 07:14: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:
Bug Depends On:    
Bug Blocks: 1075802, 1159926    

Description Jiri Belka 2013-11-29 09:35:24 UTC
Description of problem:
SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf" should be reversed. I belived it should be reverse because it should go from implicit to explicit, that is from "defaults" to "overriden" valued in sysctl.d subdir.

Found this hard when /etc/sysctl.d/ovirt-engine.conf sysctl values where again overriden.

Some apps could put their sysctl settings into sysctl.d subdir, thus those values should always win.

Version-Release number of selected component (if applicable):
tuned-0.2.19-13.el6.noarch

How reproducible:
100%

Steps to Reproduce:
1. modify as below:
# grep kernel.shmmax /etc/sysctl.conf /etc/sysctl.d/*
/etc/sysctl.conf:##kernel.shmmax = 68719476736
/etc/sysctl.conf:kernel.shmmax = 30000000
/etc/sysctl.d/ovirt-engine.conf:kernel.shmmax = 41943040
2. install tuned
3. reboot

Actual results:
values defined in files in sysctl.d dir are again overriden by ktuned RC script because of order (SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf") defined in /etc/sysconfig/ktune

Expected results:
values defined in files in sysctl.d dir should always win! (switch order in /etc/sysconfig/ktune)

Additional info:
functions file has valid ordering of sysctl conf files processing, thus why ktune reverses the order?

# sed -n '/^apply/,/^$/p' /etc/init.d/functions 
apply_sysctl() {
    sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1
    for file in /etc/sysctl.d/* ; do
        is_ignored_file "$file" && continue
        test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1
    done
}

Comment 1 Jiri Belka 2013-11-29 09:41:34 UTC
Just for archives, RHEVM sysctl stuff - BZ1027605.

Comment 3 RHEL Program Management 2013-12-02 15:54:16 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 4 Jaroslav Škarvada 2013-12-03 16:58:42 UTC
Hmm, by checking /etc/init.d/functions:apply_sysctl it does seem that RHEL-6 uses reverse order than other distros (including current Fedora) do. We need to be consistent with the init script, thus giving dev_ack+

Comment 5 Jaroslav Škarvada 2013-12-03 17:02:52 UTC
Side note: /etc/sysctl.conf is deprecated in current Fedora (F20) and supported by symlink: /etc/sysctl.d/99-sysctl.conf -> ../sysctl.conf

Comment 14 Tereza Cerna 2015-03-16 11:47:15 UTC
==============================
Verified in version:
    tuned-0.2.19-15.el6.noarch
PASSED
============================== 

# cat /etc/sysconfig/ktune | grep SYSCTL_POST
SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"

# cat /etc/sysctl.conf | grep kernel.shmmax
#kernel.shmmax = 4294967295
kernel.shmmax = 20000000

# cat /etc/sysctl.d/aaa.conf
kernel.shmmax = 30000000

== reboot == 

# tuned-adm profile virtual-guest

# sysctl kernel.shmmax
kernel.shmmax = 30000000

# grep SYSCTL_POST= `rpm -ql tuned` | grep -v \#
/etc/sysconfig/ktune:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/etc/tune-profiles/default/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/etc/tune-profiles/desktop-powersave/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/etc/tune-profiles/enterprise-storage/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/etc/tune-profiles/laptop-ac-powersave/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/etc/tune-profiles/laptop-battery-powersave/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/etc/tune-profiles/latency-performance/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/etc/tune-profiles/server-powersave/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/etc/tune-profiles/spindown-disk/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/etc/tune-profiles/throughput-performance/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/etc/tune-profiles/virtual-guest/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/etc/tune-profiles/virtual-host/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"
/usr/share/doc/tuned-0.2.19/README.ktune:    SYSCTL_POST="/etc/sysctl.conf /etc/sysctl.d/*"

==================================
Reproduced in version:
    tuned-0.2.19-13.el6_6.1.noarch
FAIL
==================================

# cat /etc/sysconfig/ktune | grep SYSCTL_POST
SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"

# cat /etc/sysctl.conf | grep kernel.shmmax
#kernel.shmmax = 4294967295
kernel.shmmax = 20000000

# cat /etc/sysctl.d/aaa.conf
kernel.shmmax = 30000000

== reboot == 

# tuned-adm profile virtual-guest

# sysctl kernel.shmmax
kernel.shmmax = 20000000

# grep SYSCTL_POST= `rpm -ql tuned` | grep -v \#
/etc/sysconfig/ktune:SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"
/etc/tune-profiles/default/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"
/etc/tune-profiles/desktop-powersave/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"
/etc/tune-profiles/enterprise-storage/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"
/etc/tune-profiles/laptop-ac-powersave/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"
/etc/tune-profiles/laptop-battery-powersave/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"
/etc/tune-profiles/latency-performance/ktune.sysconfig:SYSCTL_POST="/etc/syctl.d/* /etc/sysctl.conf"
/etc/tune-profiles/server-powersave/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"
/etc/tune-profiles/spindown-disk/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"
/etc/tune-profiles/throughput-performance/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"
/etc/tune-profiles/virtual-guest/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"
/etc/tune-profiles/virtual-host/ktune.sysconfig:SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"
/usr/share/doc/tuned-0.2.19/README.ktune:    SYSCTL_POST="/etc/sysctl.d/* /etc/sysctl.conf"

Comment 15 errata-xmlrpc 2015-07-22 07:14: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, 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://rhn.redhat.com/errata/RHBA-2015-1376.html