Bug 1524640

Summary: systemd-analyze must not succeed on failures in verify command
Product: Red Hat Enterprise Linux 7 Reporter: Tomas Dolezal <todoleza>
Component: systemdAssignee: systemd-maint
Status: CLOSED WONTFIX QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.5CC: dtardon, systemd-maint-list
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-15 07:34:00 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 Tomas Dolezal 2017-12-11 19:15:11 UTC
Description of problem:
(1) when systemd-analyze is presented with wrong unitfile, it sometimes reports success even if there are errors making the unitfile work badly.

(2) Also, it shows results for files in current directory if not asked to. It doesn't reflect the tests status via EXITCODE in this case though.

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

How reproducible:
always

Steps to Reproduce:
all invocations bellow show also results for adjacent unit files in CWD
do `systemd-analyze verify mysvc.service` and see (a)
 * exitcode is zero, failure on dependencies detected (syntax)
do `systemd-analyze verify user.slice` and see (b)
 * from example in manpage
 * fails obviously, with exitcode 1
do `systemd-analyze verify mysvc.service user.slice` and see (c)
 * fails with exitcode 1

Actual results:
(a) systemd-analyze verify mysvc.service; echo EC=$?
[/root/mytests/user.slice:2] Unknown lvalue 'WhatIsThis' in section 'Unit'
[/root/mytests/user.slice:6] Unknown section 'Service'. Ignoring.
[/usr/lib/systemd/system/ip6tables.service:3] Failed to add dependency on syslog.target,iptables.service, ignoring: Invalid argument
[/root/mytests/mysvc.service:2] Failed to add dependency on syslog.target,network.service, ignoring: Invalid argument
EC=0

(b) systemd-analyze verify user.slice; echo EC=$?
[/root/mytests/user.slice:2] Unknown lvalue 'WhatIsThis' in section 'Unit'
[/root/mytests/user.slice:6] Unknown section 'Service'. Ignoring.
[/usr/lib/systemd/system/ip6tables.service:3] Failed to add dependency on syslog.target,iptables.service, ignoring: Invalid argument
Error: org.freedesktop.systemd1.NoSuchUnit: Unit not found.
Failed to create user.slice/start: No such file or directory
user.slice: man nosuchfile(1) command failed with code 16
EC=1

(c) systemd-analyze verify user.slice mysvc.service; echo EC=$?
[/root/mytests/user.slice:2] Unknown lvalue 'WhatIsThis' in section 'Unit'
[/root/mytests/user.slice:6] Unknown section 'Service'. Ignoring.
[/usr/lib/systemd/system/ip6tables.service:3] Failed to add dependency on syslog.target,iptables.service, ignoring: Invalid argument
[/root/mytests/mysvc.service:2] Failed to add dependency on syslog.target,network.service, ignoring: Invalid argument
Error: org.freedesktop.systemd1.NoSuchUnit: Unit not found.
Failed to create user.slice/start: No such file or directory
user.slice: man nosuchfile(1) command failed with code 16
EC=1
Expected results:
non-zero exitcode in all scenarios above

Additional info:
>cat mysvc.service 
[Unit]
After=syslog.target,network.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/true
ExecStop=/usr/bin/true

[Install]
WantedBy=basic.target

>cat user.slice 
[Unit]
WhatIsThis=11
Documentation=man:nosuchfile(1)
Requires=different.service

[Service]
Desription=x

Comment 2 Tomas Dolezal 2017-12-11 19:18:03 UTC
severity medium because automated checks are useless if not observing the output.
wrongly specified dependencies cause ugly bugs in other components

Comment 5 RHEL Program Management 2021-02-15 07:34:00 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.