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-ssh state.* commands: retcode is 0 when state/pillar rendering fails #64514

Closed
4 tasks done
lkubb opened this issue Jun 21, 2023 · 1 comment · Fixed by #64515
Closed
4 tasks done

[BUG] salt-ssh state.* commands: retcode is 0 when state/pillar rendering fails #64514

lkubb opened this issue Jun 21, 2023 · 1 comment · Fixed by #64515
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@lkubb
Copy link
Contributor

lkubb commented Jun 21, 2023

Description
When applying a state via salt-ssh and highstate/lowstate/pillar rendering fails, the exit code is 0.

Setup

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • onedir packaging
  • used bootstrap to install
# /srv/salt/render_fail.sls
this state rendering fails {{ abc }}:
  test.nop

Steps to Reproduce the behavior

$ salt-ssh target state.apply render_fail
target:
      - Rendering SLS 'base:render_fail' failed: Jinja variable 'abc' is undefined; line 2

        ---
        # /srv/salt/render_fail.sls
        this state rendering fails {{ abc }}:    <======================
          test.nop
        ---
  [ERROR   ] Rendering exception occurred
  Traceback (most recent call last):
    File "/usr/lib/python3.10/site-packages/salt/utils/templates.py", line 476, in render_jinja_tmpl
      output = template.render(**decoded_context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.10/site-packages/jinja2/environment.py", line 1291, in render
      self.environment.handle_exception()
    File "/usr/lib/python3.10/site-packages/jinja2/environment.py", line 925, in handle_exception
      raise rewrite_traceback_stack(source=source)
    File "<template>", line 2, in top-level template code
  jinja2.exceptions.UndefinedError: 'abc' is undefined

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/usr/lib/python3.10/site-packages/salt/utils/templates.py", line 218, in render_tmpl
      output = render_str(tmplstr, context, tmplpath)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.10/site-packages/salt/utils/templates.py", line 482, in render_jinja_tmpl
      raise SaltRenderError("Jinja variable {}{}".format(exc, out), line, tmplstr)
  salt.exceptions.SaltRenderError: Jinja variable 'abc' is undefined; line 2

  ---
  # /srv/salt/render_fail.sls
  this state rendering fails {{ abc }}:    <======================
    test.nop
  ---
  [CRITICAL] Rendering SLS 'base:render_fail' failed: Jinja variable 'abc' is undefined; line 2

  ---
  # /srv/salt/render_fail.sls
  this state rendering fails {{ abc }}:    <======================
    test.nop
  ---
$ echo $?
0

Expected behavior
exitcode > 0

Versions Report
Tested on 3005.1, but this behavior is present in current master as well (wrote the tests + proposed fix already).

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 needs-triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants