`salt` command not returning an error code when the minion does not respond.
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 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:
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)salt-master -dsalt '*' test.pingecho $?
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.
This affects us too on 2016.11.1
+1 just hit this on 2016.11.1
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.
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'.
+1 the same on 2016.11.3
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
Any ETA or targeted version for this issue to be fixed? or maybe even looked at? Thanks!
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.
Still valid for 2018.3.0
Thank you for updating this issue. It is no longer marked as stale.
Still valid for 2019.2.4. Is there a workaround to let salt exit with non-zero code in such situation?
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.