Merge pull request #25588 from basepi/salt.ssh.retcode.25401

Fix some of the retcode work from #23105
This commit is contained in:
Colton Myers 2015-07-21 13:22:33 -06:00
commit 12b8fd05d0
2 changed files with 11 additions and 4 deletions

View File

@ -533,8 +533,12 @@ class SSH(object):
final_exit = 0
for ret in self.handle_ssh():
host = next(six.iterkeys(ret))
host_ret = ret[host].get('retcode', 0)
if host_ret != 0:
if isinstance(ret[host], dict):
host_ret = ret[host].get('retcode', 0)
if host_ret != 0:
final_exit = 1
else:
# Error on host
final_exit = 1
self.cache_job(jid, host, ret[host], fun)
@ -778,11 +782,13 @@ class Single(object):
opts_pkg['_caller_cachedir'] = self.opts['cachedir']
# Use the ID defined in the roster file
opts_pkg['id'] = self.id
retcode = opts_pkg['retcode']
retcode = 0
if '_error' in opts_pkg:
# Refresh failed
ret = json.dumps({'local': opts_pkg})
retcode = opts_pkg['retcode']
return ret, retcode
pillar = salt.pillar.Pillar(
@ -853,8 +859,10 @@ class Single(object):
result = self.wfuncs[self.fun](*self.args, **self.kwargs)
except TypeError as exc:
result = 'TypeError encountered executing {0}: {1}'.format(self.fun, exc)
retcode = 1
except Exception as exc:
result = 'An Exception occurred while executing {0}: {1}'.format(self.fun, exc)
retcode = 1
# Mimic the json data-structure that "salt-call --local" will
# emit (as seen in ssh_py_shim.py)
if isinstance(result, dict) and 'local' in result:

View File

@ -125,7 +125,6 @@ class FunctionWrapper(object):
if len(ret) < 2 and 'local' in ret:
ret = ret['local']
ret = ret.get('return', {})
ret.update({'retcode': retcode})
except ValueError:
ret = {'_error': 'Failed to return clean data',
'stderr': stderr,