RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1264080 - sysctl returns exit code 0 even on failure
Summary: sysctl returns exit code 0 even on failure
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: procps-ng
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Jan Rybar
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
: 1395050 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-09-17 13:00 UTC by Tereza Cerna
Modified: 2021-09-15 12:08 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-12-15 07:36:53 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Tereza Cerna 2015-09-17 13:00:02 UTC
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 13:23:00 UTC
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 13:47:06 UTC
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 14:23:10 UTC
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 14:40:23 UTC
(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 14:28:05 UTC
*** Bug 1395050 has been marked as a duplicate of this bug. ***

Comment 9 Jan Rybar 2018-11-06 10:57:28 UTC
Relevant bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1621940

The problem is that procps-ng/fileutils.c::close_stream() ignores ERRNO values. I sent fix to upstream a while ago. They seem to be kind of busy lately, so no response yet.

Comment 11 RHEL Program Management 2020-12-15 07:36:53 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.

Comment 12 Jan Rybar 2021-09-15 12:08:52 UTC
FYI, merged into upstream today: https://gitlab.com/procps-ng/procps/-/merge_requests/76/diffs


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