diff --git a/salt/master.py b/salt/master.py index 3cea61bf40..044a115838 100644 --- a/salt/master.py +++ b/salt/master.py @@ -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): ''' diff --git a/salt/minion.py b/salt/minion.py index c141964b2c..cddbe77303 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -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: diff --git a/salt/utils/error.py b/salt/utils/error.py index 4b01f517fb..838fd67f64 100644 --- a/salt/utils/error.py +++ b/salt/utils/error.py @@ -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')