mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +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
2c89983424
commit
a823299d96
@ -26,7 +26,7 @@ class Batch(object):
|
|||||||
self.eauth = eauth if eauth else {}
|
self.eauth = eauth if eauth else {}
|
||||||
self.quiet = quiet
|
self.quiet = quiet
|
||||||
self.local = salt.client.get_local_client(opts['conf_file'])
|
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):
|
def __gather_minions(self):
|
||||||
'''
|
'''
|
||||||
@ -44,14 +44,19 @@ class Batch(object):
|
|||||||
else:
|
else:
|
||||||
args.append(self.opts.get('expr_form', 'glob'))
|
args.append(self.opts.get('expr_form', 'glob'))
|
||||||
|
|
||||||
fret = []
|
ping_gen = self.local.cmd_iter_no_block(*args, **self.eauth)
|
||||||
for ret in self.local.cmd_iter(*args, **self.eauth):
|
wait_until = time.time() + self.opts['timeout']
|
||||||
for minion in ret:
|
|
||||||
if not self.quiet:
|
fret = set()
|
||||||
print_cli('{0} Detected for this batch run'.format(minion))
|
for ret in ping_gen:
|
||||||
fret.append(minion)
|
m = next(ret.iterkeys())
|
||||||
# Returns <type 'list'>
|
if m is not None:
|
||||||
return sorted(frozenset(fret))
|
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):
|
def get_bnum(self):
|
||||||
'''
|
'''
|
||||||
@ -131,6 +136,14 @@ class Batch(object):
|
|||||||
time.sleep(0.02)
|
time.sleep(0.02)
|
||||||
parts = {}
|
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:
|
for queue in iters:
|
||||||
try:
|
try:
|
||||||
# Gather returns until we get to the bottom
|
# Gather returns until we get to the bottom
|
||||||
|
Loading…
Reference in New Issue
Block a user