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
14.1k stars 5.47k forks source link

salt-call with --retcode-passthrough returns exit code 2 if sls is empty #39172

Open lorengordon opened 7 years ago

lorengordon commented 7 years ago

Description of Issue/Question

If I create an empty sls file (or it is rendered to an empty sls file), then using salt-call with --retcode-passthrough will return an exit code of 2. This is essentially a noop, so I'm not sure why that would be considered an error.

Setup

# cat /srv/salt/states/base/test.sls
{# empty state #}

Steps to Reproduce Issue

# salt-call --local --retcode-passthrough state.sls test
local:

Summary for local
-----------
Succeeded: 0
Failed:   0
-----------
Total states run:    0
Total run time:  0.000 ms
# echo $?
2

Versions Report

# salt-call --versions-report
Salt Version:
           Salt: 2016.11.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.6.0
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8.1
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.5.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: centos 6.8 Final
        machine: x86_64
        release: 2.6.32-642.13.1.el6.x86_64
         system: Linux
        version: CentOS 6.8 Final
Ch3LL commented 7 years ago

@lorengordon i can see where your logic is here, because if someone adds jinja to a sls file to only run on certain conditions you can expect some files to be empty.

Heres a docker container to quickly replicate this issue:

  1. docker run -it -v /home/ch3ll/git/salt/:/testing/ ch3ll/issues:39172 (where /home/ch3ll/git/salt is a local cloned git repo of salt)
  2. salt-call --local --retcode-passthrough state.sls test
  3. echo $?
stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

lorengordon commented 6 years ago

Should probably be kept open...

stale[bot] commented 6 years ago

Thank you for updating this issue. It is no longer marked as stale.

bbinet commented 4 years ago

I'm also facing the same issue, even without passing salt-call the --retcode-passthrough flag:

$ python3 .tmp/thin/salt-call -c /tmp/removeme/setupify --state-output=changes state.apply setupify.nosudo
.tmp/thin/py3/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.7) or chardet (2.3.0) doesn't match a supported version!
  RequestsDependencyWarning)
local:

Summary for local
-----------
Succeeded: 0
Failed:   0
-----------
Total states run:    0
Total run time:  0.000 ms
$ root@e1cd9c2fa617:/tmp/removeme/setupify# echo $?
2

Anyone knows how I could fix this issue?

Ch3LL commented 4 years ago

what version are you seeing this on? on 2019.2.2 im getting an exit code of 1. Not saying the issue is resolved with that, but just curious why we are seeing different exit codes without --retcode-passthrough