Bug 1264080 - sysctl returns exit code 0 even on failure
sysctl returns exit code 0 even on failure
Status: NEW
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: procps-ng (Show other bugs)
7.2
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Jan Rybar
BaseOS QE - Apps
: MoveUpstream
: 1395050 (view as bug list)
Depends On:
Blocks: 1380361
  Show dependency treegraph
 
Reported: 2015-09-17 09:00 EDT by Tereza Cerna
Modified: 2017-09-27 23:45 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Tereza Cerna 2015-09-17 09:00:02 EDT
Sysctl does not work in tuned-2.5.1-3.el7.noarch. It is working in fedora, but not in RHEL.

Value is not set up:

1] Try to set up value directly with sysctl:

  $ sysctl -n kernel.sched_rt_runtime_us
  950000
  $ sysctl kernel.sched_rt_runtime_us=11
  sysctl: setting key "kernel.sched_rt_runtime_us": Nepřípustný argument
  kernel.sched_rt_runtime_us = 111
  $ echo $?
  0
  $ sysctl -n kernel.sched_rt_runtime_us
  950000
  $

  sysctl should return error exit code.

2] Try to set up indirectly with tuned profile activation

  $ cat new-profile/tuned.conf 
  [sysctl]
  kernel.sched_rt_runtime_us = 111
  $ systemctl restart tuned
  $ tuned-adm profile new-profile
  $ sysctl -n kernel.sched_rt_runtime_us
  950000
  $

  There are no error in /var/log/tuned/tuned.conf after profile activation.

  $ tuned-adm verify
Verification failed, current system settings differ from the preset profile.
See tuned.log for details. You can mostly fix this by Tuned restart, e.g.:
  service tuned restart
  $ cat /var/log/tuned/tuned.log | grep ERROR
2015-09-17 08:59:01,076 ERROR    tuned.plugins.base: verify: failed: kernel.sched_rt_runtime_us = 950000, expected 111
  $
Comment 1 Jaroslav Škarvada 2015-09-17 09:23:00 EDT
Reassigning to sysctl, tuned cannot detect that the sysctl command failed because sysctl is returning exit code 0, even if the kernel setting failed.

Reproducer:
# sysctl kernel.sched_rt_runtime_us=111111
sysctl: setting key "kernel.sched_rt_runtime_us": Invalid argument
kernel.sched_rt_runtime_us = 111111
# echo $?
0
# sysctl kernel.sched_rt_runtime_us
kernel.sched_rt_runtime_us = 950000

Expected result:
Exit code<>0 if the sysctl settings failed.
Comment 3 Jaroslav Škarvada 2015-09-17 09:47:06 EDT
Regarding the error itself, I don't know why the setting itself is rejected by kernel on RHEL-7:

# echo 111111 > /proc/sys/kernel/sched_rt_runtime_us 
-bash: echo: write error: Invalid argument

but:
# echo 950001  > /proc/sys/kernel/sched_rt_runtime_us
# echo $?
0

I think it should work and it works on Fedora 22. Filled kernel bug 1264091.

By using 950001 in tuned profile, it works correctly for me, so there is probably no tuned bug.
Comment 4 Jaromír Cápík 2015-10-05 10:23:10 EDT
Ahoj.

The sysctl command is often used for writing multiple kernel variables at once and in such case it simply ignores the failed ones. It was always like that. We can't stop processing the variables somewhere in the middle, otherwise we would end up with unfinished kernel configuration during the startup. And since multiple variables can be configured with one sysctl call, we would have to define some rules for the return codes in order to satisfy the particular scenarios (all variables correctly set, some of the variable settings failed, all variable settings failed). Or shall we rather return the number of failures? This needs to be discussed upstream first.

Regards,
Jaromir.
Comment 5 Jaroslav Škarvada 2015-10-05 10:40:23 EDT
(In reply to Jaromír Cápík from comment #4)
> Ahoj.
> 
> The sysctl command is often used for writing multiple kernel variables at
> once and in such case it simply ignores the failed ones. It was always like
> that. We can't stop processing the variables somewhere in the middle,
> otherwise we would end up with unfinished kernel configuration during the
> startup. And since multiple variables can be configured with one sysctl
> call, we would have to define some rules for the return codes in order to
> satisfy the particular scenarios (all variables correctly set, some of the
> variable settings failed, all variable settings failed). Or shall we rather
> return the number of failures? This needs to be discussed upstream first.
> 
> Regards,
> Jaromir.

I have no problem with multiple return codes for failure, but there definitely need to be mechanism how to detect that something failed, i.e. return code != 0.
Comment 7 Jan Rybar 2016-11-29 09:28:05 EST
*** Bug 1395050 has been marked as a duplicate of this bug. ***

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