mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Re-work batching to more closely match CLI usage
In the regular CLI we consider a job as completed once all minions aren't running the job anymore. In this batching implementation we will ping all minions, wait up to timeout, then start the batching. In the event of minions returning during the batching we'll add them to the list of targets.
This commit is contained in:
parent
b119faecf4
commit
3e67cb54ff
@ -24,7 +24,7 @@ class Batch(object):
|
||||
self.eauth = eauth if eauth else {}
|
||||
self.quiet = quiet
|
||||
self.local = salt.client.get_local_client(opts['conf_file'])
|
||||
self.minions = self.__gather_minions()
|
||||
self.minions, self.ping_gen = self.__gather_minions()
|
||||
|
||||
def __gather_minions(self):
|
||||
'''
|
||||
@ -42,14 +42,19 @@ class Batch(object):
|
||||
else:
|
||||
args.append(self.opts.get('expr_form', 'glob'))
|
||||
|
||||
fret = []
|
||||
for ret in self.local.cmd_iter(*args, **self.eauth):
|
||||
for minion in ret:
|
||||
if not self.quiet:
|
||||
print_cli('{0} Detected for this batch run'.format(minion))
|
||||
fret.append(minion)
|
||||
# Returns <type 'list'>
|
||||
return sorted(frozenset(fret))
|
||||
ping_gen = self.local.cmd_iter_no_block(*args, **self.eauth)
|
||||
wait_until = time.time() + self.opts['timeout']
|
||||
|
||||
fret = set()
|
||||
for ret in ping_gen:
|
||||
m = next(ret.iterkeys())
|
||||
if m is not None:
|
||||
fret.add(m)
|
||||
if time.time() > wait_until:
|
||||
break
|
||||
if m is None:
|
||||
time.sleep(0.1)
|
||||
return (list(fret), ping_gen)
|
||||
|
||||
def get_bnum(self):
|
||||
'''
|
||||
@ -129,6 +134,14 @@ class Batch(object):
|
||||
time.sleep(0.02)
|
||||
parts = {}
|
||||
|
||||
# see if we found more minions
|
||||
for ping_ret in self.ping_gen:
|
||||
if ping_ret is None:
|
||||
break
|
||||
if ping_ret not in self.minions:
|
||||
self.minions.append(ping_ret)
|
||||
to_run.append(ping_ret)
|
||||
|
||||
for queue in iters:
|
||||
try:
|
||||
# Gather returns until we get to the bottom
|
||||
|
Loading…
Reference in New Issue
Block a user