mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #40018 from meaksh/2016.3-handling-timeouts-for-manage.up-runner
Allows overriding 'timeout' and 'gather_job_timeout' to 'manage.up' runner call
This commit is contained in:
commit
8dcffc7751
2 changed files with 18 additions and 6 deletions
|
@ -220,7 +220,7 @@ class LocalClient(object):
|
|||
Return the information about a given job
|
||||
'''
|
||||
log.debug('Checking whether jid {0} is still running'.format(jid))
|
||||
timeout = self.opts['gather_job_timeout']
|
||||
timeout = kwargs.get('gather_job_timeout', self.opts['gather_job_timeout'])
|
||||
|
||||
pub_data = self.run_job(tgt,
|
||||
'saltutil.find_job',
|
||||
|
@ -921,6 +921,7 @@ class LocalClient(object):
|
|||
|
||||
if timeout is None:
|
||||
timeout = self.opts['timeout']
|
||||
gather_job_timeout = kwargs.get('gather_job_timeout', self.opts['gather_job_timeout'])
|
||||
start = int(time.time())
|
||||
|
||||
# timeouts per minion, id_ -> timeout time
|
||||
|
@ -1019,7 +1020,7 @@ class LocalClient(object):
|
|||
jinfo_iter = []
|
||||
else:
|
||||
jinfo_iter = self.get_returns_no_block('salt/job/{0}'.format(jinfo['jid']))
|
||||
timeout_at = time.time() + self.opts['gather_job_timeout']
|
||||
timeout_at = time.time() + gather_job_timeout
|
||||
# if you are a syndic, wait a little longer
|
||||
if self.opts['order_masters']:
|
||||
timeout_at += self.opts.get('syndic_wait', 1)
|
||||
|
|
|
@ -30,7 +30,7 @@ from salt.exceptions import SaltClientError
|
|||
FINGERPRINT_REGEX = re.compile(r'^([a-f0-9]{2}:){15}([a-f0-9]{2})$')
|
||||
|
||||
|
||||
def status(output=True):
|
||||
def status(output=True, timeout=None, gather_job_timeout=None):
|
||||
'''
|
||||
Print the status of all known salt minions
|
||||
|
||||
|
@ -42,8 +42,14 @@ def status(output=True):
|
|||
'''
|
||||
ret = {}
|
||||
client = salt.client.get_local_client(__opts__['conf_file'])
|
||||
|
||||
if not timeout:
|
||||
timeout = __opts__['timeout']
|
||||
if not gather_job_timeout:
|
||||
gather_job_timeout = __opts__['gather_job_timeout']
|
||||
|
||||
try:
|
||||
minions = client.cmd('*', 'test.ping', timeout=__opts__['timeout'])
|
||||
minions = client.cmd('*', 'test.ping', timeout=timeout, gather_job_timeout=gather_job_timeout)
|
||||
except SaltClientError as client_error:
|
||||
print(client_error)
|
||||
return ret
|
||||
|
@ -128,7 +134,7 @@ def down(removekeys=False):
|
|||
return ret
|
||||
|
||||
|
||||
def up(): # pylint: disable=C0103
|
||||
def up(timeout=None, gather_job_timeout=None): # pylint: disable=C0103
|
||||
'''
|
||||
Print a list of all of the minions that are up
|
||||
|
||||
|
@ -137,8 +143,13 @@ def up(): # pylint: disable=C0103
|
|||
.. code-block:: bash
|
||||
|
||||
salt-run manage.up
|
||||
salt-run manage.up timeout=5 gather_job_timeout=5
|
||||
'''
|
||||
ret = status(output=False).get('up', [])
|
||||
ret = status(
|
||||
output=False,
|
||||
timeout=timeout,
|
||||
gather_job_timeout=gather_job_timeout
|
||||
).get('up', [])
|
||||
return ret
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue