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

[BUG] salt-run runner module exit code is 0 when exception raised #61173

Closed
TeddyAndrieux opened this issue Nov 3, 2021 · 1 comment
Closed
Assignees
Labels
Bug broken, incorrect, or confusing behavior

Comments

@TeddyAndrieux
Copy link
Contributor

TeddyAndrieux commented Nov 3, 2021

Description
A clear and concise description of what the bug is.

If I have a runner module that raises an exception the exit code of the salt-run command is still 0

Steps to Reproduce the behavior
(Include debug logs if possible and relevant)

A really simple test using a built-in runner

$ salt-run error.error name="Exception" message="This is an error."
Exception occurred in runner error.error: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/client/mixins.py", line 390, in low
    data["return"] = func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/runners/error.py", line 29, in error
    salt.utils.error.raise_error(name=name, message=message)
  File "/usr/lib/python3.6/site-packages/salt/utils/error.py", line 33, in raise_error
    raise ex(message)
Exception: This is an error.
$ echo $?
0

Expected behavior
A clear and concise description of what you expected to happen.

Exit code not equal to 0 when the runner module raises an exception

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
salt-run 3004

Additional context

The only way I found to have a non-zero exit code for our custom runner is to return a dict with retcode set to non-zero

@whytewolf
Copy link
Collaborator

closing since #64479 and #64545 are merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior
Projects
None yet
Development

No branches or pull requests

6 participants