Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1362461 - 'systemctl status' returns 0 for failed services
Summary: 'systemctl status' returns 0 for failed services
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd
Version: 7.3
Hardware: All
OS: Unspecified
high
medium
Target Milestone: beta
: ---
Assignee: systemd-maint
QA Contact: Frantisek Sumsal
Lucie Maňásková
URL:
Whiteboard:
Depends On:
Blocks: 1362179
TreeView+ depends on / blocked
 
Reported: 2016-08-02 09:11 UTC by Stanislav Zidek
Modified: 2016-11-04 00:55 UTC (History)
4 users (show)

Fixed In Version: systemd-219-25.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-04 00:55:30 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2216 normal SHIPPED_LIVE systemd bug fix and enhancement update 2016-11-03 13:24:51 UTC

Description Stanislav Zidek 2016-08-02 09:11:49 UTC
Description of problem:
When I unsuccessfully start a service and then query for status, I start to get zero exit code in RHEL-7.3.

Version-Release number of selected component (if applicable):
systemd-219-24.el7

How reproducible:
always

Steps to Reproduce:
1. echo 'AuthenticationMethods bogusoption' >>/etc/ssh/sshd_config
2. systemctl restart sshd
3. systemctl status sshd
4. echo $?

Actual results:
...
# echo $?
0

Expected results:
...
# echo $?
3
(or something else non-zero)

Additional info:
* I set priority to high, because I can imagine this might break e.g. some monitoring scripts etc.
* Old version I was comparing to is systemd-219-19.el7

Comment 3 Lukáš Nykrýn 2016-08-02 13:52:25 UTC
This got broken with https://github.com/lnykryn/systemd-rhel/commit/41bb37959c96b8fddc13b37384b3453393517f4f

Upstream has the same problem:
https://github.com/systemd/systemd/issues/3864

Comment 5 Lukáš Nykrýn 2016-08-03 08:22:24 UTC
Lathough this bug sounds scary, the im pact is quite limited, this is only a problem for services, that have Restart=on-failure and big RestartSec. Those services are not in failed state, because systemd is trying to start them again.

Anyway, I have send a patch to upstream to consider such services as PROGRAM_NOT_RUNNING. https://github.com/systemd/systemd/pull/3874

Comment 6 Lukáš Nykrýn 2016-08-03 11:48:42 UTC
The second version of the patch still waits to be merged in upstream, but setting an optimistic devel_ack for that patch.

Comment 7 Lukáš Nykrýn 2016-08-04 08:38:29 UTC
pushed to staging ->
https://github.com/lnykryn/systemd-rhel/commit/94fec84897ab40bf2bc92f0d395a93ecac1b45be
-> post

Comment 9 Frantisek Sumsal 2016-08-16 11:53:56 UTC
Verified on RHEL 7.3 Beta with systemd-219-26.el7.

Old package:
# echo 'AuthenticationMethods garbage' >> /etc/ssh/sshd_config
# systemctl restart sshd
Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.
# systemctl status sshd
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2016-08-16 07:50:09 EDT; 5s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
  Process: 1297 ExecStart=/usr/sbin/sshd $OPTIONS (code=exited, status=255)
 Main PID: 907 (code=exited, status=0/SUCCESS)

Aug 16 07:50:09 qeos-178 systemd[1]: sshd.service: control process ex...5
Aug 16 07:50:09 qeos-178 systemd[1]: Failed to start OpenSSH server d....
Aug 16 07:50:09 qeos-178 systemd[1]: Unit sshd.service entered failed....
Aug 16 07:50:09 qeos-178 systemd[1]: sshd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
# echo $?
0

New package:
# echo 'AuthenticationMethods garbage' >> /etc/ssh/sshd_config
# systemctl restart sshd
Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.
# systemctl status sshd
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2016-08-16 07:46:20 EDT; 10s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
  Process: 4121 ExecStart=/usr/sbin/sshd $OPTIONS (code=exited, status=255)
 Main PID: 3829 (code=exited, status=0/SUCCESS)

Aug 16 07:46:20 qeos-176 systemd[1]: sshd.service: control process ex...5
Aug 16 07:46:20 qeos-176 systemd[1]: Failed to start OpenSSH server d....
Aug 16 07:46:20 qeos-176 systemd[1]: Unit sshd.service entered failed....
Aug 16 07:46:20 qeos-176 systemd[1]: sshd.service failed.
Aug 16 07:46:20 qeos-176 sshd[4121]: Unknown authentication method "g...t
Aug 16 07:46:20 qeos-176 sshd[4121]: /etc/ssh/sshd_config line 154: i....
Hint: Some lines were ellipsized, use -l to show in full.
# echo $?
3

Comment 11 errata-xmlrpc 2016-11-04 00:55:30 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-2016-2216.html


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