Skip to content

Commit

Permalink
Back-port #34256 to 2016.3 (#34343)
Browse files Browse the repository at this point in the history
* detect running from master in State.event method

This changes `State.event` to detect whether the state that invoked `fire_event` is running on the master. This fixes an issue where the `fire_event` requisite doesn't work when being used in orchestration states.

* fix linting issues
  • Loading branch information
Nicole Thomas committed Jun 28, 2016
1 parent 0b9cb60 commit a9ea344
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions salt/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1932,7 +1932,13 @@ def event(self, chunk_ret, length, fire_event=False):
chunk is evaluated an event will be set up to the master with the
results.
'''
if not self.opts.get('local') and (self.opts.get('state_events', True) or fire_event) and self.opts.get('master_uri'):
if not self.opts.get('local') and (self.opts.get('state_events', True) or fire_event):
if not self.opts.get('master_uri'):
ev_func = lambda ret, tag, preload=None: salt.utils.event.get_master_event(
self.opts, self.opts['sock_dir'], listen=False).fire_event(ret, tag)
else:
ev_func = self.functions['event.fire_master']

ret = {'ret': chunk_ret}
if fire_event is True:
tag = salt.utils.event.tagify(
Expand All @@ -1948,7 +1954,7 @@ def event(self, chunk_ret, length, fire_event=False):
)
ret['len'] = length
preload = {'jid': self.jid}
self.functions['event.fire_master'](ret, tag, preload=preload)
ev_func(ret, tag, preload=preload)

def call_chunk(self, low, running, chunks):
'''
Expand Down

0 comments on commit a9ea344

Please sign in to comment.