Support job data

This commit is contained in:
Mike Place 2014-10-24 11:37:03 -06:00
parent 59d5c47c7d
commit 9db48612ae
3 changed files with 11 additions and 8 deletions

View File

@ -257,7 +257,7 @@ class Master(SMaster):
def __handle_error_react(self, event):
log.error('Received minion error from [{minion}]: {data}'.format(minion=event['id'], data=event['data']))
log.error('Received minion error from [{minion}]: {data}'.format(minion=event['id'], data=event['data']['exception']))
def __register_reactions(self):
'''

View File

@ -1089,7 +1089,7 @@ class Minion(MinionBase):
except Exception:
msg = 'The minion function caused an exception'
log.warning(msg, exc_info_on_loglevel=logging.DEBUG)
salt.utils.error.fire_raw_exception(salt.exceptions.MinionError(msg), opts)
salt.utils.error.fire_exception(salt.exceptions.MinionError(msg), opts, job=data)
ret['return'] = '{0}: {1}'.format(msg, traceback.format_exc())
ret['out'] = 'nested'
else:

View File

@ -32,14 +32,17 @@ def raise_error(name=None, args=None, message=''):
else:
raise ex(message)
def fire_raw_exception(exc, opts, node='minion'):
'''
Fire raw exception across the event bus
'''
def pack_exception(exc):
if hasattr(exc, 'pack'):
packed_exception = exc.pack()
else:
packed_exception = {'message': exc.__unicode__(), 'args': exc.args}
return packed_exception
def fire_exception(exc, opts, job={}, node='minion'):
'''
Fire raw exception across the event bus
'''
event = salt.utils.event.SaltEvent(node, opts=opts)
event.fire_event(packed_exception, '_salt_error')
event.fire_event({'exception': pack_exception(exc),
'job': job}, '_salt_error')