salt icon indicating copy to clipboard operation
salt copied to clipboard

`salt` command not returning an error code when the minion does not respond.

Open StyXman opened this issue 10 years ago • 14 comments

Description of Issue/Question

If a minion does not respond, the salt command stills return a OK status:

m.dione@svc-salt [~] > sudo salt ct243-qa state.highstate                                                                                                                                                                              14:00
ct243-qa:
    Minion did not return. [No response]
m.dione@svc-salt [~] > echo $?                                                                                                                                                                                                         14:01
0

I would expect a non-zero exit code, so I can do something about the error in a shell script.

Versions Report

Server:

m.dione@svc-salt [~] > salt --versions-report                                                                                                                                                                                          14:33
Salt Version:
           Salt: 2016.3.3
 
Dependency Versions:
           cffi: 0.8.6
       cherrypy: Not Installed
       dateutil: 2.2
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
         Jinja2: 2.7.3
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.2
   mysql-python: 1.2.3
      pycparser: 2.10
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.9 (default, Jun 29 2016, 13:08:31)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.4.0
           RAET: Not Installed
          smmap: 0.8.2
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
 
System Versions:
           dist: debian 8.6 
        machine: x86_64
        release: 3.16.0-4-amd64
         system: Linux
        version: debian 8.6 

Minion:

# salt-call --versions-report
Salt Version:
           Salt: 2016.3.4
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.5
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 0.9.1
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.0.1
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
 
System Versions:
           dist: Ubuntu 14.04 trusty
        machine: x86_64
        release: 4.4.0-45-generic
         system: Linux
        version: Ubuntu 14.04 trusty

StyXman avatar Nov 21 '16 13:11 StyXman

@StyXman looks like i'm also able to replicate this on 2016.3.4

[root@f6dae542edf4 testing]# salt '*' test.ping
f6dae542edf4:
    Minion did not return. [No response]
[root@f6dae542edf4 testing]# echo $?
0

I also tested this on 2015.8.5 so does not seem to be a regression but still nee to get this fixed up. Thanks.

Also here is a docker container for anyone that wants to quickly replicate:

  1. docker run -it -v /home/ch3ll/git/salt:/testing/ ch3ll/issues:37802 /bin/bash (where /home/ch3ll/git/salt is a local clone git salt repo)
  2. salt-master -d
  3. salt '*' test.ping
  4. echo $?

Ch3LL avatar Nov 22 '16 16:11 Ch3LL

qq, what if some salt-minions returned and some are not, what could be return code?

From my understanding, correct me if I am wrong, as long as salt execution command complete successfully, no matter of the salt-minion results, it should always return zero. Unless we are sure that return code of salt cli executions on salt master should rely on minions.

hu-dabao avatar Nov 23 '16 19:11 hu-dabao

This affects us too on 2016.11.1

ewapptus avatar Dec 22 '16 14:12 ewapptus

+1 just hit this on 2016.11.1

mlalpho avatar Dec 23 '16 04:12 mlalpho

Job executing was highstate run. I would expect "no response" to be treated as a failure and be able to react as such instead of the states continuing on as if the highstate run and job return were successful.

mlalpho avatar Dec 23 '16 05:12 mlalpho

what if some salt-minions returned and some are not, what could be return code?

I think in that case the state should be error too, possibly a different error from 'all minions failed'.

StyXman avatar Jan 10 '17 21:01 StyXman

+1 the same on 2016.11.3

gaetanquentin avatar Jun 23 '17 14:06 gaetanquentin

so i worked around this to make our CD work and fail the build in case the minion is not connected by wrapping salt into a bash script

#!/bin/bash

echo $1

BLAH=$(salt $1 test.ping)

if [[ "$BLAH" == *"Not connected"* ]]; then
   exit 1
else
   exit 0
fi

damaex17 avatar Aug 17 '17 15:08 damaex17

Any ETA or targeted version for this issue to be fixed? or maybe even looked at? Thanks!

djsly avatar Dec 13 '17 20:12 djsly

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.

stale[bot] avatar Apr 07 '19 20:04 stale[bot]

Still valid for 2018.3.0

andrii-rymar avatar Sep 27 '19 10:09 andrii-rymar

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

stale[bot] avatar Oct 22 '19 14:10 stale[bot]

Still valid for 2019.2.4. Is there a workaround to let salt exit with non-zero code in such situation?

seanzhang422 avatar Oct 07 '20 21:10 seanzhang422

Fixed in #49217 (merged 2018-08-21, fluorine, commit 23fec9c255b — adds retcode: EX_GENERIC to LocalClient.get_cli_event_returns for [Not connected] / [No response] yields). Covered by tests/pytests/integration/cli/test_salt.py::test_missing_minion on 3006.x/3007.x/3008.x/master, passing. Closing.

dwoz avatar Jun 29 '26 00:06 dwoz