service.status currently reports an error on FreeBSD if the service isn't running
In FreeBSD, service onestatus currently returns 1 if either the service is not running, or it simply doesn't exist. This seems to be proper handling of the service not existing case, but Salt should not treat a down status as an error:
# salt-call service.status moo
[ERROR ] Command '/usr/sbin/service moo onestatus' failed with return code: 1
[ERROR ] output: moo does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d)
local:
False
# salt-call service.status inetd
[ERROR ] Command '/usr/sbin/service inetd onestatus' failed with return code: 1
[ERROR ] output: inetd is not running.
local:
False
We possibly need to parse the return on a 1, and in the case of 'is not running', squelch the error?
The simple state that is triggering this is service.dead:
freebsd_inetd:
service.dead:
- name: inetd
Looking a Debuntu, it seems to be in the same boat. I guess this is just a low priority bug that might need some extra logic in all service modules.
[INFO ] Executing command ['service', 'mpt-statusd', 'status'] in directory '/root'
[ERROR ] Command ['service', 'mpt-statusd', 'status'] failed with return code: 3
[ERROR ] output: * mpt-statusd is not running
local:
False
@JaseFace, thanks for the report. Return codes are traditionally inconsistent across distros and commands and are always a challenge to interpret correctly.
The spurious logging is removed by https://github.com/saltstack/salt/pull/33294.