mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
address filehandle/event leak in async run_job invocations
extending on the idea used in #32145, when _check_pub_data is called it it will
create jid subscriptions, regardless of whether anyone will ever come back to
retrieve them; in the case of local_async calls noone ever does.
In addition to the above, we use the listen kwarg provided by c59a5adb0d
to
know whether we need to subscribe to events in addition to ensuring the ioloop
is listening before a call is made.
This should fix #40245, #20639, #36374
This commit is contained in:
parent
1941426218
commit
36a0f6d8ca
1 changed files with 11 additions and 4 deletions
|
@ -246,7 +246,7 @@ class LocalClient(object):
|
|||
|
||||
return pub_data
|
||||
|
||||
def _check_pub_data(self, pub_data):
|
||||
def _check_pub_data(self, pub_data, listen=True):
|
||||
'''
|
||||
Common checks on the pub_data data structure returned from running pub
|
||||
'''
|
||||
|
@ -279,7 +279,13 @@ class LocalClient(object):
|
|||
print('No minions matched the target. '
|
||||
'No command was sent, no jid was assigned.')
|
||||
return {}
|
||||
else:
|
||||
|
||||
# don't install event subscription listeners when the request is async
|
||||
# and doesn't care. this is important as it will create event leaks otherwise
|
||||
if not listen:
|
||||
return pub_data
|
||||
|
||||
if self.opts.get('order_masters'):
|
||||
self.event.subscribe('syndic/.*/{0}'.format(pub_data['jid']), 'regex')
|
||||
|
||||
self.event.subscribe('salt/job/{0}'.format(pub_data['jid']))
|
||||
|
@ -343,7 +349,7 @@ class LocalClient(object):
|
|||
# Convert to generic client error and pass along message
|
||||
raise SaltClientError(general_exception)
|
||||
|
||||
return self._check_pub_data(pub_data)
|
||||
return self._check_pub_data(pub_data, listen=listen)
|
||||
|
||||
def gather_minions(self, tgt, expr_form):
|
||||
return salt.utils.minions.CkMinions(self.opts).check_minions(tgt, tgt_type=expr_form)
|
||||
|
@ -408,7 +414,7 @@ class LocalClient(object):
|
|||
# Convert to generic client error and pass along message
|
||||
raise SaltClientError(general_exception)
|
||||
|
||||
raise tornado.gen.Return(self._check_pub_data(pub_data))
|
||||
raise tornado.gen.Return(self._check_pub_data(pub_data, listen=listen))
|
||||
|
||||
def cmd_async(
|
||||
self,
|
||||
|
@ -449,6 +455,7 @@ class LocalClient(object):
|
|||
tgt_type,
|
||||
ret,
|
||||
jid=jid,
|
||||
listen=False,
|
||||
**kwargs)
|
||||
try:
|
||||
return pub_data['jid']
|
||||
|
|
Loading…
Add table
Reference in a new issue