Skip to content

Commit

Permalink
Merge pull request #25588 from basepi/salt.ssh.retcode.25401
Browse files Browse the repository at this point in the history
Fix some of the retcode work from #23105
  • Loading branch information
basepi committed Jul 21, 2015
2 parents bb6974a + adbdfa9 commit 12b8fd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 11 additions & 3 deletions salt/client/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,12 @@ def run(self):
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)
Expand Down Expand Up @@ -778,11 +782,13 @@ def run_wfunc(self):
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(
Expand Down Expand Up @@ -853,8 +859,10 @@ def run_wfunc(self):
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:
Expand Down
1 change: 0 additions & 1 deletion salt/client/ssh/wrapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def caller(*args, **kwargs):
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,
Expand Down

0 comments on commit 12b8fd0

Please sign in to comment.