mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Don't run jid twice on the same minion.
This commit is contained in:
parent
b466d84664
commit
192ccabd30
@ -890,6 +890,8 @@ VALID_OPTS = {
|
||||
'proxy_password': str,
|
||||
'proxy_port': int,
|
||||
|
||||
# Minion de-dup jid cache max size
|
||||
'minion_jid_queue_hwm': int,
|
||||
}
|
||||
|
||||
# default configurations
|
||||
@ -1125,6 +1127,7 @@ DEFAULT_MINION_OPTS = {
|
||||
'proxy_username': '',
|
||||
'proxy_password': '',
|
||||
'proxy_port': 0,
|
||||
'minion_jid_queue_hwm': 100,
|
||||
}
|
||||
|
||||
DEFAULT_MASTER_OPTS = {
|
||||
|
@ -728,6 +728,7 @@ class MinionManager(MinionBase):
|
||||
self.auth_wait = self.opts['acceptance_wait_time']
|
||||
self.max_auth_wait = self.opts['acceptance_wait_time_max']
|
||||
self.minions = []
|
||||
self.jid_queue = []
|
||||
|
||||
if HAS_ZMQ:
|
||||
zmq.eventloop.ioloop.install()
|
||||
@ -765,6 +766,7 @@ class MinionManager(MinionBase):
|
||||
False,
|
||||
io_loop=self.io_loop,
|
||||
loaded_base_name='salt.loader.{0}'.format(s_opts['master']),
|
||||
jid_queue=self.jid_queue,
|
||||
)
|
||||
self.minions.append(minion)
|
||||
self.io_loop.spawn_callback(self._connect_minion, minion)
|
||||
@ -832,7 +834,7 @@ class Minion(MinionBase):
|
||||
This class instantiates a minion, runs connections for a minion,
|
||||
and loads all of the functions into the minion
|
||||
'''
|
||||
def __init__(self, opts, timeout=60, safe=True, loaded_base_name=None, io_loop=None): # pylint: disable=W0231
|
||||
def __init__(self, opts, timeout=60, safe=True, loaded_base_name=None, io_loop=None, jid_queue=None): # pylint: disable=W0231
|
||||
'''
|
||||
Pass in the options dict
|
||||
'''
|
||||
@ -849,6 +851,7 @@ class Minion(MinionBase):
|
||||
# Flag meaning minion has finished initialization including first connect to the master.
|
||||
# True means the Minion is fully functional and ready to handle events.
|
||||
self.ready = False
|
||||
self.jid_queue = jid_queue
|
||||
|
||||
if io_loop is None:
|
||||
if HAS_ZMQ:
|
||||
@ -1187,6 +1190,16 @@ class Minion(MinionBase):
|
||||
)
|
||||
log.debug('Command details {0}'.format(data))
|
||||
|
||||
# Don't duplicate jobs
|
||||
log.debug('Started JIDs: {0}'.format(self.jid_queue))
|
||||
if self.jid_queue is not None:
|
||||
if data['jid'] in self.jid_queue:
|
||||
return
|
||||
else:
|
||||
self.jid_queue.append(data['jid'])
|
||||
if len(self.jid_queue) > self.opts['minion_jid_queue_hwm']:
|
||||
self.jid_queue.pop(0)
|
||||
|
||||
if isinstance(data['fun'], six.string_types):
|
||||
if data['fun'] == 'sys.reload_modules':
|
||||
self.functions, self.returners, self.function_errors, self.executors = self._load_modules()
|
||||
|
Loading…
Reference in New Issue
Block a user