mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Support job data
This commit is contained in:
parent
59d5c47c7d
commit
9db48612ae
@ -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):
|
||||
'''
|
||||
|
@ -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:
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user