saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
13.99k stars 5.47k forks source link

When using pillar.items _errors does not trigger retcode 5 as expected #54209

Open ryanwalder opened 4 years ago

ryanwalder commented 4 years ago

Description of Issue

When running pillar.items if a pillar fails to render and is caught in _errors it does not set the retcode to 5 as expected. It does fail and set the correct retcode when running state.apply however.

eg:

vagrant@cs-vagrant-test-ryan-01:~$ sudo salt-call pillar.items --retcode-passthrough
local:
    ----------
    _errors:
        - Rendering SLS 'test.ryan' failed, render error:
          while constructing a mapping
            in "<unicode string>", line 1, column 1:
              roles:
              ^
          found conflicting ID 'pip'
            in "<unicode string>", line 22, column 1:
              pip: {}
  rest_of_pillar:
        - renders_fine

Setup

Setup pillar to read from 2 files

first.sls

foo: bar

second.sls

one: two

one: {}

Steps to Reproduce Issue

Do the above and run salt-call pillar.items --retcode-passthrough you should see second.sls fail due to duplicate keys, then echo $? and you'll see the retcode is 0, not 5 as described by the docs.

Versions Report

Same version on minion & master

vagrant@cs-vagrant-test-ryan-01:~$ sudo salt-call --versions-report
Salt Version:
           Salt: 2019.2.0

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.4.2
      docker-py: Not Installed
          gitdb: 0.6.4
      gitpython: 1.0.1
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.3
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.12 (default, Nov 12 2018, 14:36:49)
   python-gnupg: 0.3.8
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: 0.9.0
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: Ubuntu 16.04 xenial
         locale: UTF-8
        machine: x86_64
        release: 4.4.0-142-generic
         system: Linux
        version: Ubuntu 16.04 xenial
dmurphy18 commented 4 years ago

@ryanwalder Thanks for filing an issue on this problem. Actually found that even with just the incorrect second.sls by itself that error reporting is incorrect.

root@deb9min:/srv/pillar# cat top.sls base: '*':

[DEBUG ] Results of YAML rendering: OrderedDict([(u'base', OrderedDict([(u'', [u'second'])]))]) [PROFILE ] Time (in seconds) to render '/srv/pillar/top.sls' using 'yaml' renderer: 0.000646114349365 [DEBUG ] LazyLoaded confirm_top.confirm_top [DEBUG ] LazyLoaded compound_match.match [DEBUG ] compound_match: t9 ? [DEBUG ] LazyLoaded glob_match.match [DEBUG ] compound_match t9 ? "*" => "True" [DEBUG ] compile template: /srv/pillar/second.sls [DEBUG ] Jinja search path: [u'/srv/pillar', u'/srv/spm/pillar'] [PROFILE ] Time (in seconds) to render '/srv/pillar/second.sls' using 'jinja' renderer: 0.00430393218994 [DEBUG ] Rendered data from file: /srv/pillar/second.sls: one: two one: {}

[CRITICAL] Rendering SLS 'second' failed, render error: while constructing a mapping in "", line 1, column 1 found conflicting ID 'one' in "", line 2, column 1 Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/salt/pillar/init.py", line 736, in render_pstate defaults) File "/usr/lib/python2.7/dist-packages/salt/template.py", line 101, in compile_template ret = render(input_data, saltenv, sls, render_kwargs) File "/usr/lib/python2.7/dist-packages/salt/renderers/yaml.py", line 59, in render raise SaltRenderError(exc) SaltRenderError: while constructing a mapping in "", line 1, column 1 found conflicting ID 'one' in "", line 2, column 1 [CRITICAL] Pillar render error: Rendering SLS 'second' failed. Please see master log for details. [DEBUG ] LazyLoaded jinja.render [DEBUG ] LazyLoaded yaml.render [DEBUG ] LazyLoaded pillar.items [DEBUG ] LazyLoaded direct_call.execute [DEBUG ] Determining pillar cache [DEBUG ] LazyLoaded jinja.render [DEBUG ] LazyLoaded yaml.render [DEBUG ] compile template: /srv/pillar/top.sls [DEBUG ] Jinja search path: [u'/srv/pillar', u'/srv/spm/pillar'] [PROFILE ] Time (in seconds) to render '/srv/pillar/top.sls' using 'jinja' renderer: 0.00513482093811 [DEBUG ] Rendered data from file: /srv/pillar/top.sls: base: '*':

[DEBUG ] Results of YAML rendering: OrderedDict([(u'base', OrderedDict([(u'', [u'second'])]))]) [PROFILE ] Time (in seconds) to render '/srv/pillar/top.sls' using 'yaml' renderer: 0.000614166259766 [DEBUG ] LazyLoaded confirm_top.confirm_top [DEBUG ] LazyLoaded compound_match.match [DEBUG ] compound_match: t9 ? [DEBUG ] LazyLoaded glob_match.match [DEBUG ] compound_match t9 ? "*" => "True" [DEBUG ] compile template: /srv/pillar/second.sls [DEBUG ] Jinja search path: [u'/srv/pillar', u'/srv/spm/pillar'] [PROFILE ] Time (in seconds) to render '/srv/pillar/second.sls' using 'jinja' renderer: 0.00421905517578 [DEBUG ] Rendered data from file: /srv/pillar/second.sls: one: two one: {}

[CRITICAL] Rendering SLS 'second' failed, render error: while constructing a mapping in "", line 1, column 1 found conflicting ID 'one' in "", line 2, column 1 Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/salt/pillar/init.py", line 736, in render_pstate defaults) File "/usr/lib/python2.7/dist-packages/salt/template.py", line 101, in compile_template ret = render(input_data, saltenv, sls, render_kwargs) File "/usr/lib/python2.7/dist-packages/salt/renderers/yaml.py", line 59, in render raise SaltRenderError(exc) SaltRenderError: while constructing a mapping in "", line 1, column 1 found conflicting ID 'one' in "", line 2, column 1 [CRITICAL] Pillar render error: Rendering SLS 'second' failed. Please see master log for details. [DEBUG ] LazyLoaded nested.output local:

_errors:
    - Rendering SLS 'second' failed. Please see master log for details.

root@deb9min:/srv/pillar# echo $? 0