Repository navigation
Description
I'm using a command like this below to execute state.highstate on one machine at a time, with the intention that it stop on the first failure. But, it's not stopping even though there is a failure.
sudo salt -b 1 --failhard -G 'roles:foo' state.highstate
The cause of the failure is a http_test.ping custom module function I wrote that checks that an HTTP call is succeeding. I gave it a bogus path to force it to fail. I'm testing this against two minions. Looking at the minion logs I can see the calls are failing. But, the output I get from the salt command above is essentially:
Executing run on ['some-machine-A']
retcode:
0
Executing run on ['some-machine-B']
some-machine-B: <-- highlighted red
(... lots of SLS state output ...)
----------
ID: Ping the web app <-- all highlighted red
Function: http_test.ping
Result: False
Comment: Call to http://localhost:80/pingping failed. Error: HTTP 404: NOT FOUND. HTTP status: 404
Started: 22:52:49.686395
Duration: 57.519 ms
Changes:
(... more SLS state output ...)
So, you can see that the Ping the web app call is failing and has Result: False. This happens for both machines. But, the retcode for both machines is apparently 0. I ran the same command again with --out=yaml appended, which showed me that retcode is 0 for both machines.
Maybe this isn't a problem with the batch mode but instead a problem with how retcode is determined. Am I missing something? Shouldn't the retcode be non-zero since the state has Result: False?
Activity
matthayes commentedon Dec 12, 2015
I've also tried following the events by running
sudo salt-run state.event pretty=True. Here I also see thatretcodeis 0 for bothstate.highstateexecutions. How is the value ofretcodedetermined? Is it not based on the state success or failure?matthayes commentedon Dec 12, 2015
As a test I tried adding some logging to
get_retcodethat I saw mentioned in #22855 . What I found is that the finalelseis executing, meaning that the defaultretcodeof 0 is returned. I also tried dumpingret. It looks like it only consists of keys corresponding to each state that is executed. I don't see any useful return values that could be used to detect failure.Also, if I remove
-b 1 --failhardfrom the command,get_retcodeis logging different output (below). This time there is aretcodewith value 0, which still doesn't seem right since one of the states has a false result.Also this seems to indicate a bug in how
get_retcodeis called in these two cases. In batch mode it appears that the value ofretis passed toget_retcode, which doesn't haveretcode. But when not in batch mode the parent object that containsretis passed to it, which does containretcode.matthayes commentedon Dec 12, 2015
@jacksontj thoughts on this?
matthayes commentedon Dec 14, 2015
@basepi , wanted to bring this to your attention as it is related to your suggestion in #1038 .
matthayes commentedon Dec 14, 2015
To summarize, I think there are two issues:
retcodecoming back from the minion forstate.highstateis zero even though one of theresultvalues is false.retcodewe would never know because the wrong object is passed toget_retcodeinsalt.py.lorengordon commentedon Dec 14, 2015
Does
saltsupport--retcode-passthroughor is that only an option forsalt-call? (I only use masterless, so I don't have a master to check with...)https://docs.saltstack.com/en/latest/ref/cli/salt-call.html#cmdoption-salt-call--retcode-passthrough
matthayes commentedon Dec 14, 2015
Not that I've seen. I think that's only supported by
salt-call.basepi commentedon Dec 14, 2015
thanks for the ping, @matthayes. This looks like something we need to get fixed.
matthayes commentedon Dec 14, 2015
I can help diagnose the issue on my side but I need some pointers for what code to check. I've been adding logging to dig deeper but I've reached the limit of my familiarity with the Salt code. Can you point me to where in the code the minion returns the retcode to the master? Or let me know if there is something I can do to help find the problem. I was working on automating some deployment but now I'm stuck until this is fixed so I am motivated to identify the problem :)
65 remaining items
DmitryKuzmenko commentedon Feb 12, 2016
@matthayes I've just fixed this. All details provided in the PR #31164
danlsgiga commentedon Feb 12, 2016
This may fix an issue I've opened for a few months already. #24996
Thanks for the fix @DmitryKuzmenko
DmitryKuzmenko commentedon Feb 12, 2016
@danlsgiga you're welcome!
matthayes commentedon Feb 16, 2016
@DmitryKuzmenko thanks for fixing this!