You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Corerelates to code central or existential to SaltP1Priority 1bugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
is there a reason why test.* returns False and exits with bash exit code 0 instead of 1 ?
~# salt some-minion file.access /var/run/reboot-required f; echo $?<>:
False
0
~# salt some-other-minion file.access /var/run/reboot-required f; echo $?<>:
True
0
Reacted by Bruno P. Kinoshita, Arnold Bechtoldt, Alexey Dubkov, Richard Hansen, Gabriel Le Breton, EYJ, Paul Peereboom, uvsmtid, Vladimir Lazarenko, Logi Ragnarsson and 8 more
Thanks for bringing this up, I believe the behavior you are seeing is the expected behavior. The command salt <minion> file.access is executed successfully in both cases, so the return value in both cases is 0, regardless of the result of the file.access function itself.
My reason for thinking a return of 0 was appropriate in this circumstance is that I am thinking of a return code as local to a system. Since salt runs successfully as intended on the master, it's return code would not be affected by the state of the remote minion. I admit that my reasoning on this is not very solid and am inclined to rather support your arguments.
A further consultation of the applicable standards as you have suggested is needed. I believe there is an issue somewhere about generally refactoring return statuses/return codes. I can't find it at the moment, but that ought to be referenced here.
Exit codes have been normalized in #48361 for the upcoming Fluorine release. The following conditions will set a nonzero exit code:
An exception is raised
The code being run sets __context__['retcode'] to a nonzero value
The return data for a given function is a dictionary with either a result or success key in it, which resolves as False
file.file_exists would not trigger any of those conditions, however. The problem here is if we use something like __context__['retcode'] in file.file_exists to denote failure, then we've marked the run as failed, so if any state invokesfile.file_exists, this would make salt reutrn a nonzero exit code even if the file not existing was expected (and therefore not an error).
I'm a bit confused about the status - I've just picked up salt 2018.3.4 which has the latest fixes in for return codes for salt-call. If I pass the argument --retcode-passthrough to salt-call I now get non-zero exit codes for failures but without it I always get 0 - is this the expected functionality at the current time? Anybody know when this functionality becomes the default?
I think this is expected, as far as I know. To get status code from operation executed by salt-call you have to use --retcode-passthrough if nothing was changed.
Corerelates to code central or existential to SaltP1Priority 1bugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around
Activity
jfindlay commentedon Nov 26, 2014
Thanks for bringing this up, I believe the behavior you are seeing is the expected behavior. The command
salt <minion> file.accessis executed successfully in both cases, so the return value in both cases is0, regardless of the result of thefile.accessfunction itself.Deshke commentedon Nov 26, 2014
hey, sorry. i would expect a different behavior, like if my test goes wrong, the return code should be 1 (http://tldp.org/LDP/abs/html/exitcodes.html) regardless if my salt command runs successfully.
jfindlay commentedon Dec 1, 2014
My reason for thinking a return of
0was appropriate in this circumstance is that I am thinking of a return code as local to a system. Sincesaltruns successfully as intended on the master, it's return code would not be affected by the state of the remote minion. I admit that my reasoning on this is not very solid and am inclined to rather support your arguments.A further consultation of the applicable standards as you have suggested is needed. I believe there is an issue somewhere about generally refactoring return statuses/return codes. I can't find it at the moment, but that ought to be referenced here.
jfindlay commentedon Dec 2, 2014
Here it is: #7013.
tjyang commentedon Dec 3, 2014
@jfindlay , thanks for the info on #7013. This bug should be classified above "Low Severity", IMO.
106 remaining items
Oloremo commentedon Nov 3, 2018
Wait, what is the current status of retcodes for salt operations? It's been 4 years since the issue was created...
terminalmage commentedon Nov 6, 2018
Exit codes have been normalized in #48361 for the upcoming Fluorine release. The following conditions will set a nonzero exit code:
__context__['retcode']to a nonzero valueresultorsuccesskey in it, which resolves asFalsefile.file_existswould not trigger any of those conditions, however. The problem here is if we use something like__context__['retcode']infile.file_existsto denote failure, then we've marked the run as failed, so if any state invokesfile.file_exists, this would make salt reutrn a nonzero exit code even if the file not existing was expected (and therefore not an error).oliver-dungey commentedon Mar 4, 2019
I'm a bit confused about the status - I've just picked up salt
2018.3.4which has the latest fixes in for return codes forsalt-call. If I pass the argument--retcode-passthroughtosalt-callI now get non-zero exit codes for failures but without it I always get 0 - is this the expected functionality at the current time? Anybody know when this functionality becomes the default?adubkov commentedon Mar 4, 2019
I think this is expected, as far as I know. To get status code from operation executed by salt-call you have to use
--retcode-passthroughif nothing was changed.terminalmage commentedon Mar 26, 2019
@oliver-dungey As explained above, the retcode changes are in the Fluorine release (2019.2.0).
terminalmage commentedon Mar 26, 2019
@saltstack/team-core Since Fluorine was released, this can be closed.
dz-pyps commentedon Jun 13, 2019
Using salt version below, the issue with the incorrect exit code is still present when you add --batch-size and --batch-wait parameters
sudo salt -v -L minion-1,minion-2 --batch-size 50% --batch-wait 1 state.apply queue=True test-stateEven though there is an error:
salt exit status is 0.
terminalmage commentedon Jun 13, 2019
Please open a new issue. Commenting on a closed issue doesn't do much good.