mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Fix for #18256
With this new setup of everything firing events, this seemed like a good time to tackle this infinite recursion from the reactor. What this does is pass a "user" (Reactor) to all jobs that the reactor starts. Then the reactor skips all events created by that username-- thereby only reacting to events not caused by itself.
This commit is contained in:
parent
1843eb0ba6
commit
30c3e57957
@ -130,6 +130,9 @@ class Reactor(multiprocessing.Process, salt.state.Compiler):
|
||||
self.wrap = ReactWrap(self.opts)
|
||||
|
||||
for data in self.event.iter_events(full=True):
|
||||
# skip all events fired by ourselves
|
||||
if data['data'].get('user') == self.wrap.event_user:
|
||||
continue
|
||||
reactors = self.list_reactors(data['tag'])
|
||||
if not reactors:
|
||||
continue
|
||||
@ -147,6 +150,7 @@ class ReactWrap(object):
|
||||
'''
|
||||
# class-wide cache of clients
|
||||
client_cache = None
|
||||
event_user = 'Reactor'
|
||||
|
||||
def __init__(self, opts):
|
||||
self.opts = opts
|
||||
@ -166,7 +170,13 @@ class ReactWrap(object):
|
||||
l_fun = getattr(self, low['state'])
|
||||
try:
|
||||
f_call = salt.utils.format_call(l_fun, low)
|
||||
l_fun(*f_call.get('args', ()), **f_call.get('kwargs', {}))
|
||||
kwargs = f_call.get('kwargs', {})
|
||||
|
||||
# TODO: pick one...
|
||||
kwargs['__user__'] = self.event_user
|
||||
kwargs['user'] = self.event_user
|
||||
|
||||
l_fun(*f_call.get('args', ()), **kwargs)
|
||||
except Exception:
|
||||
log.error(
|
||||
'Failed to execute {0}: {1}\n'.format(low['state'], l_fun),
|
||||
|
Loading…
Reference in New Issue
Block a user