salt icon indicating copy to clipboard operation
salt copied to clipboard

service.status currently reports an error on FreeBSD if the service isn't running

Open JaseFace opened this issue 11 years ago • 4 comments

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

JaseFace avatar May 07 '15 00:05 JaseFace

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 avatar May 07 '15 00:05 JaseFace

@JaseFace, thanks for the report. Return codes are traditionally inconsistent across distros and commands and are always a challenge to interpret correctly.

jfindlay avatar May 11 '15 17:05 jfindlay

Hi @JaseFace

I made a Pr in order help fixing this. Check this if you have time.

Thanks

abednarik avatar May 09 '16 17:05 abednarik

The spurious logging is removed by https://github.com/saltstack/salt/pull/33294.

terminalmage avatar May 17 '16 00:05 terminalmage