Fix return data structure for runner (issue #39169).

Previously, the return code of the runner (if any) was supplied in
ret['data']['retcode']. This was problematic if ret['data'] was later processed
by check_state_result. With this change, runners return the optional return
code in ret['retcode'], like the other code (modules, etc.) already did before.
This commit is contained in:
Sebastian Marsching 2017-02-24 13:02:52 +01:00
parent 53e78d67f6
commit 88c2d9a540
2 changed files with 11 additions and 3 deletions

View file

@ -39,7 +39,15 @@ class SaltRun(parsers.SaltRunOptionParser):
pr = activate_profile(profiling_enabled)
try:
ret = runner.run()
if isinstance(ret, dict) and 'retcode' in ret.get('data', {}):
# In older versions ret['data']['retcode'] was used
# for signaling the return code. This has been
# changed for the orchestrate runner, but external
# runners might still use it. For this reason, we
# also check ret['data']['retcode'] if
# ret['retcode'] is not available.
if isinstance(ret, dict) and 'retcode' in ret:
self.exit(ret['retcode'])
elif isinstance(ret, dict) and 'retcode' in ret.get('data', {}):
self.exit(ret['data']['retcode'])
finally:
output_profile(

View file

@ -57,9 +57,9 @@ def orchestrate(mods, saltenv='base', test=None, exclude=None, pillar=None):
ret = {'data': {minion.opts['id']: running}, 'outputter': 'highstate'}
res = salt.utils.check_state_result(ret['data'])
if res:
ret['data']['retcode'] = 0
ret['retcode'] = 0
else:
ret['data']['retcode'] = 1
ret['retcode'] = 1
return ret
# Aliases for orchestrate runner