mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add a configurable timer for minion return retries
When a minion return cannot be processed in a timely manner, a SaltReqTimeoutError is raised. However, the default wait time before the minion will retry sending the return data was not being passed, so it would wait a full 60 seconds. This reduces that timeout to (by default) a maximum of 4 seconds, and randomizes it to prevent a retry flood as you scale up the number of minions.
This commit is contained in:
parent
b22286476e
commit
453b883820
1 changed files with 36 additions and 3 deletions
|
@ -21,6 +21,7 @@ import time
|
|||
import traceback
|
||||
import types
|
||||
from random import randint, shuffle
|
||||
from salt.config import DEFAULT_MINION_OPTS
|
||||
from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin
|
||||
|
||||
from stat import S_IMODE
|
||||
|
@ -901,6 +902,30 @@ class Minion(MinionBase):
|
|||
self.connected = True
|
||||
return opts['master']
|
||||
|
||||
def _return_retry_timer(self):
|
||||
'''
|
||||
Based on the minion configuration, either return a randomized timer or
|
||||
just return the value of the return_retry_timer.
|
||||
'''
|
||||
msg = 'Minion return retry timer set to {0} seconds'
|
||||
if self.opts['return_retry_random']:
|
||||
try:
|
||||
random_retry = randint(1, self.opts['return_retry_timer'])
|
||||
except ValueError:
|
||||
# Catch wiseguys using negative integers here
|
||||
log.error(
|
||||
'Invalid value ({0}) for return_retry_timer, must be a '
|
||||
'positive integer'.format(self.opts['return_retry_timer'])
|
||||
)
|
||||
log.debug(msg.format(DEFAULT_MINION_OPTS['return_retry_timer']))
|
||||
return DEFAULT_MINION_OPTS['return_retry_timer']
|
||||
else:
|
||||
log.debug(msg.format(random_retry) + ' (randomized)')
|
||||
return random_retry
|
||||
else:
|
||||
log.debug(msg.format(self.opts['return_retry_timer']))
|
||||
return self.opts['return_retry_timer']
|
||||
|
||||
def _prep_mod_opts(self):
|
||||
'''
|
||||
Returns a copy of the opts with key bits stripped out
|
||||
|
@ -1253,7 +1278,10 @@ class Minion(MinionBase):
|
|||
ret['metadata'] = data['metadata']
|
||||
else:
|
||||
log.warning('The metadata parameter must be a dictionary. Ignoring.')
|
||||
minion_instance._return_pub(ret)
|
||||
minion_instance._return_pub(
|
||||
ret,
|
||||
timeout=minion_instance._return_retry_timer()
|
||||
)
|
||||
if data['ret']:
|
||||
if 'ret_config' in data:
|
||||
ret['ret_config'] = data['ret_config']
|
||||
|
@ -1310,7 +1338,10 @@ class Minion(MinionBase):
|
|||
ret['fun_args'] = data['arg']
|
||||
if 'metadata' in data:
|
||||
ret['metadata'] = data['metadata']
|
||||
minion_instance._return_pub(ret)
|
||||
minion_instance._return_pub(
|
||||
ret,
|
||||
timeout=minion_instance._return_retry_timer()
|
||||
)
|
||||
if data['ret']:
|
||||
if 'ret_config' in data:
|
||||
ret['ret_config'] = data['ret_config']
|
||||
|
@ -2316,7 +2347,9 @@ class Syndic(Minion):
|
|||
pretag=tagify(self.opts['id'], base='syndic'),
|
||||
)
|
||||
for jid in self.jids:
|
||||
self._return_pub(self.jids[jid], '_syndic_return')
|
||||
self._return_pub(self.jids[jid],
|
||||
'_syndic_return',
|
||||
timeout=self._return_retry_timer())
|
||||
self._reset_event_aggregation()
|
||||
|
||||
def destroy(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue