Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if status of service is stop, there is not an error with it #23015

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions salt/modules/upstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,15 @@ def status(name, sig=None):
return bool(__salt__['status.pid'](sig))
cmd = ['service', name, 'status']
if _service_is_upstart(name):
return 'start/running' in __salt__['cmd.run'](cmd, python_shell=False)
return not bool(__salt__['cmd.retcode'](cmd, python_shell=False))
# decide result base on cmd output, thus ignore retcode,
# which makes cmd output not at error lvl even when cmd fail.
return 'start/running' in __salt__['cmd.run'](cmd, python_shell=False,
ignore_retcode=True)
# decide result base on retcode, thus ignore output (set quite)
# because there is no way to avoid logging at error lvl when
# service is not running - retcode != 0 (which is totally relevant).
return not bool(__salt__['cmd.retcode'](cmd, python_shell=False,
quite=True))


def _get_service_exec():
Expand Down