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
{{ message }}
Repository navigation
Salt exit codes are inconsistent and undocumented #7013
I would like to see salt give well-defined exit codes that are described in the man.1 page. Looking through the code base, it appears that sometimes salt exits with -1, 1, 2, or 42 -- and it's unclear when it exits with which. Other times salt exits by raising SaltSystemExit (on one occasion passing code=42). And sometimes an outputter will print an error but has no mechanism for passing an error state back the calling function, giving an error on screen but an exit code of 0.
I would like to see a clear reason for each exit code. I would also like to have a way for error information to propagate back through the call stack so that system exits can be consolidated to a single class.
Indeed. I'm provisioning a large number of hosts via salt and the provisioning is automated. When I do salt 'CFS-CSE-013443.domain.com state.hightstate' and any errors occur I need the salt command to return a proper error code. Currently I get a 0.
I'm using salt for continuous deployment from a Jenkins CI server. The problem is that if the deployment fails, the exit code is more often than not zero, so the Jenkins CI server sees the deployment as being successful even though it fails. I've bodged together a solution where I grep the output for "Failed" but it's a long way from being ideal.
Being forced to hack around issue after issue in our CI & Deployment toolchain due to salt returning ... worse than useless... flat out misleading Exit Codes. Each hack takes me one step closer to being required to completely replace salt for every duty in our CI & Deployment chain... which kinda sucks.
Ive taken some notes on the issue of the error pathways... but its 2am my time and I need some sleep before a 7am meeting. So ill have to post the notes tomorrow ... at the moment its about 200 lines long without much in the way of anything beyond being a list of all the places salt can call exit and produce a return code.
I may make a pull request for this tomorrow after i document it all... would 1 big pull request be best or a few smaller ones... the changes are littered through the code. Then theres the issue of 'default behaviour' but to be fair I want salt to 'fail safe' by assuming an error far more frequently.
Ok, to give an update on my work here. Ive been digging through source code, and since it looks like when I'm done, I'll be issuing a pull request containing anything from at least 25 through to over 200 changes, I'm writing up a nice long explanation of whats wrong before I post any kind of fix.
Pull request!
This seems the best way to avoid requiring the modification of every states code to provide more args/kwargs back up to the calling code path so a more efficient check can be performed.
Activity
thatch45 commentedon Sep 3, 2013
Yes, we might need to change a few of them as well...
grantmcwilliams commentedon Nov 18, 2013
Indeed. I'm provisioning a large number of hosts via salt and the provisioning is automated. When I do salt 'CFS-CSE-013443.domain.com state.hightstate' and any errors occur I need the salt command to return a proper error code. Currently I get a 0.
suprememoocow commentedon Dec 4, 2013
I'm using salt for continuous deployment from a Jenkins CI server. The problem is that if the deployment fails, the exit code is more often than not zero, so the Jenkins CI server sees the deployment as being successful even though it fails. I've bodged together a solution where I grep the output for "Failed" but it's a long way from being ideal.
thedrow commentedon Dec 4, 2013
@suprememoocow I just dropped salt from our continuous deployment flow because of this. Grepping didn't always work.
techdragon commentedon Feb 11, 2014
Being forced to hack around issue after issue in our CI & Deployment toolchain due to salt returning ... worse than useless... flat out misleading Exit Codes. Each hack takes me one step closer to being required to completely replace salt for every duty in our CI & Deployment chain... which kinda sucks.
kiorky commentedon Feb 11, 2014
I also concur in the idea at least not to have an exit code of 0 if any of states run failed in case of a state run (sls, highstate, etc)
kiorky commentedon Feb 11, 2014
As a workaround, we use a shell function to parse log to know if we failed or not : https://github.com/makinacorpus/makina-states/blob/master/_scripts/boot-salt.sh#L931
kiorky commentedon Feb 11, 2014
@thedrow, you can grep with yaml outputter, it will work as we do.
techdragon commentedon Feb 11, 2014
Ive taken some notes on the issue of the error pathways... but its 2am my time and I need some sleep before a 7am meeting. So ill have to post the notes tomorrow ... at the moment its about 200 lines long without much in the way of anything beyond being a list of all the places salt can call exit and produce a return code.
techdragon commentedon Feb 11, 2014
I may make a pull request for this tomorrow after i document it all... would 1 big pull request be best or a few smaller ones... the changes are littered through the code. Then theres the issue of 'default behaviour' but to be fair I want salt to 'fail safe' by assuming an error far more frequently.
techdragon commentedon Feb 12, 2014
Ok, to give an update on my work here. Ive been digging through source code, and since it looks like when I'm done, I'll be issuing a pull request containing anything from at least 25 through to over 200 changes, I'm writing up a nice long explanation of whats wrong before I post any kind of fix.
techdragon commentedon Feb 17, 2014
Pull request!
This seems the best way to avoid requiring the modification of every states code to provide more args/kwargs back up to the calling code path so a more efficient check can be performed.
techdragon commentedon Mar 17, 2014
Finally had time to sit down and redo this work. Now for
😄
... 😴
Fix for broken salt cmd return codes - issue saltstack#7013
Merge pull request #11337 from techdragon/fix-hightstate-failure-retcode
JensRantil commentedon Jul 12, 2014
#11337 did not document the exit code. I created an issue for it here: #14155.