Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1073481

Summary: systeclt's commands 'is-failed' or 'is-active return unknown in result when state is inactive
Product: Red Hat Enterprise Linux 7 Reporter: Miroslav Lisik <mlisik>
Component: systemdAssignee: systemd-maint
Status: CLOSED WONTFIX QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: awilliam, jkortus, jscotka, lnykryn, ralongi, systemd-maint-list
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-08-21 08:08:43 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:

Description Miroslav Lisik 2014-03-06 14:03:06 UTC
Description of problem:
systemctl's command 'is-failed' returns in resulting output string:
active - when service is in active state
failed - when service is in failed state
unknown - other

Missing 'inactive' in resulting output when service is inactive.

systemctl's command 'is-failed' returns in resulting output string:
active - when service is in active state
failed - when service is in failed state
unknown - other

Missing 'inactive' in resulting output when service is inactive.

Version-Release number of selected component (if applicable):
systemd-208-4.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1. Try systemctl's commands 'is-active' and 'is-failed' on inactive service
e.g.:
# systemctl stop pacemaker

# systemctl is-active pacemaker
unknown
# systemctl is-failed pacemaker
unknown


Actual results:
systemctl's commands 'is-active' and 'is-failed' return string 'unknown' in resulting output when service state is known and inactive.

Expected results:
systemctl's commands 'is-active' and 'is-failed' should return string 'inactive' in resulting output when service state is inactive.

Additional info:

Comment 2 RHEL Program Management 2014-03-22 05:51:03 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 3 Lukáš Nykrýn 2014-08-21 08:08:43 UTC
Problem here is that there is difference between unit file and unit. is-active and is-failed operates strictly on units. We can't say that pacemaker is inactive, because we simply just see that there is no such unit and we can't decide if it is the case that service was stopped and removed by garbage collector or there is no unit file at all.
So I am sorry but this is WONTFIX/CANTFIX/NOTABUG for me.

Comment 4 Jaroslav Kortus 2014-08-21 09:56:50 UTC
Lukas, I don't understand your explanation here.

What's the difference between unit and unit-file? systemd can clearly determine if the service a) exists and b) is active or stopped or dead or failed.

So why can't this knowledge get propagated via is-failed command?
# systemctl status pacemaker
pacemaker.service - Pacemaker High Availability Cluster Manager
   Loaded: loaded (/usr/lib/systemd/system/pacemaker.service; disabled)
   Active: inactive (dead)

# systemctl is-failed pacemaker
unknown

This does not make much sense to me.

Comment 5 Lukáš Nykrýn 2014-08-21 10:52:02 UTC
Unit file is file on the disk, unit is a structure in systemd memory, unit does not need an unit file and to save memory we don't have units for unit files which are not needed.

Comment 6 Jaroslav Kortus 2014-08-21 18:01:10 UTC
ok and now once again (as you did not respond to it):

So why can't this knowledge get propagated via is-failed command?
# systemctl status pacemaker
pacemaker.service - Pacemaker High Availability Cluster Manager
   Loaded: loaded (/usr/lib/systemd/system/pacemaker.service; disabled)
   Active: inactive (dead)

# systemctl is-failed pacemaker
unknown

Comment 7 Adam Williamson 2014-09-09 08:29:37 UTC
This actually seems to work on F21:

[adamw@adam gnome-initial-setup (f21 %)]$ systemctl status iscsid.service
● iscsid.service - Open-iSCSI
   Loaded: loaded (/usr/lib/systemd/system/iscsid.service; disabled)
   Active: inactive (dead)
     Docs: man:iscsid(8)
           man:iscsiadm(8)
[adamw@adam gnome-initial-setup (f21 %)]$ systemctl is-failed iscsid
inactive
[adamw@adam gnome-initial-setup (f21 %)]$ 

did something change, Lukas?

Comment 8 Lukáš Nykrýn 2014-09-09 08:34:40 UTC
The same thing works in rhel

[lnykryn@notas initscripts(rhel7-branch)]$ systemctl is-active avahi-daemon.service
unknown
[lnykryn@notas initscripts(rhel7-branch)]$ systemctl status avahi-daemon.service
avahi-daemon.service - Avahi mDNS/DNS-SD Stack
   Loaded: loaded (/usr/lib/systemd/system/avahi-daemon.service; disabled)
   Active: inactive (dead)

[lnykryn@notas initscripts(rhel7-branch)]$ systemctl is-active avahi-daemon.service
inactive


Status is more complex function with creates a unit in systemd manager. Than you can view its status through is-active until garbage collectors eats it.

Comment 9 Adam Williamson 2014-09-09 08:54:12 UTC
ah, I see.

Comment 10 Jaroslav Kortus 2014-09-09 09:51:05 UTC
well, then it works in a very inconsistent way. The commands should return the same result unless the service state has changed. Making one's result depend on what has been run before is more kind of your internal magic than anything user friendly ;).

Is there any dependable machine-parsable command that would produce reliable output?

Comment 11 Lukáš Nykrýn 2014-09-09 10:58:27 UTC
> Is there any dependable machine-parsable command that would produce reliable
> output?

Sure

$ systemctl show bluetooth.service -p ActiveState
ActiveState=inactive

And there is a stability promise for this command. So you should definitely use this one in scripts.

Comment 12 Rick Alongi 2017-01-27 17:34:34 UTC
*** Bug 1417251 has been marked as a duplicate of this bug. ***