mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #35682 from vutny/backport-35659
[BACKPORT] Fix empty `fun_agrs` field in Reactor generated events
This commit is contained in:
commit
433743f609
1 changed files with 21 additions and 16 deletions
|
@ -256,11 +256,7 @@ class SyncClientMixin(object):
|
|||
jid = low.get('__jid__', salt.utils.jid.gen_jid())
|
||||
tag = low.get('__tag__', tagify(jid, prefix=self.tag_prefix))
|
||||
|
||||
# This avoids including kwargs dict as args list in low data.
|
||||
# We only need to update event data.
|
||||
fun_args = low.get('args', [])
|
||||
data = {'fun': '{0}.{1}'.format(self.client, fun),
|
||||
'fun_args': fun_args + ([low['kwargs']] if low.get('kwargs', False) else []),
|
||||
'jid': jid,
|
||||
'user': low.get('__user__', 'UNKNOWN'),
|
||||
}
|
||||
|
@ -280,11 +276,13 @@ class SyncClientMixin(object):
|
|||
# Suppress printing of return event (this keeps us from printing
|
||||
# runner/wheel output during orchestration).
|
||||
print_func = None
|
||||
|
||||
namespaced_event = salt.utils.event.NamespacedEvent(
|
||||
event,
|
||||
tag,
|
||||
print_func=print_func
|
||||
)
|
||||
|
||||
# TODO: document these, and test that they exist
|
||||
# TODO: Other things to inject??
|
||||
func_globals = {'__jid__': jid,
|
||||
|
@ -295,8 +293,6 @@ class SyncClientMixin(object):
|
|||
'__jid_event__': weakref.proxy(namespaced_event),
|
||||
}
|
||||
|
||||
func_globals['__jid_event__'].fire_event(data, 'new')
|
||||
|
||||
try:
|
||||
verify_fun(self.functions, fun)
|
||||
|
||||
|
@ -332,6 +328,7 @@ class SyncClientMixin(object):
|
|||
args = f_call.get('args', ())
|
||||
else:
|
||||
args = low['args']
|
||||
|
||||
if 'kwargs' not in low:
|
||||
if f_call is None:
|
||||
f_call = salt.utils.format_call(
|
||||
|
@ -351,6 +348,10 @@ class SyncClientMixin(object):
|
|||
else:
|
||||
kwargs = low['kwargs']
|
||||
|
||||
# Update the event data with loaded args and kwargs
|
||||
data['fun_args'] = args + ([kwargs] if kwargs else [])
|
||||
func_globals['__jid_event__'].fire_event(data, 'new')
|
||||
|
||||
# Initialize a context for executing the method.
|
||||
with tornado.stack_context.StackContext(self.functions.context_dict.clone):
|
||||
data['return'] = self.functions[fun](*args, **kwargs)
|
||||
|
@ -360,26 +361,30 @@ class SyncClientMixin(object):
|
|||
data['return'] = str(ex)
|
||||
else:
|
||||
data['return'] = 'Exception occurred in {0} {1}: {2}'.format(
|
||||
self.client,
|
||||
fun,
|
||||
traceback.format_exc(),
|
||||
)
|
||||
self.client,
|
||||
fun,
|
||||
traceback.format_exc(),
|
||||
)
|
||||
data['success'] = False
|
||||
|
||||
namespaced_event.fire_event(data, 'ret')
|
||||
|
||||
try:
|
||||
salt.utils.job.store_job(
|
||||
self.opts,
|
||||
{'id': self.opts['id'],
|
||||
'tgt': self.opts['id'],
|
||||
'jid': data['jid'],
|
||||
'return': data,
|
||||
},
|
||||
{
|
||||
'id': self.opts['id'],
|
||||
'tgt': self.opts['id'],
|
||||
'jid': data['jid'],
|
||||
'return': data,
|
||||
},
|
||||
event=None,
|
||||
mminion=self.mminion,
|
||||
)
|
||||
except salt.exceptions.SaltCacheError:
|
||||
log.error('Could not store job cache info. Job details for this run may be unavailable.')
|
||||
log.error('Could not store job cache info. '
|
||||
'Job details for this run may be unavailable.')
|
||||
|
||||
# if we fired an event, make sure to delete the event object.
|
||||
# This will ensure that we call destroy, which will do the 0MQ linger
|
||||
log.info('Runner completed: {0}'.format(data['jid']))
|
||||
|
|
Loading…
Add table
Reference in a new issue