SMinion need wait future from eval_master

This commit is contained in:
Sergey Kacheev 2016-03-09 12:48:38 +06:00
parent c0868307df
commit 3b4425652b

View file

@ -448,6 +448,7 @@ class MinionBase(object):
log.error(msg)
sys.exit(salt.defaults.exitcodes.EX_GENERIC)
# FIXME: if SMinion don't define io_loop, it can't switch master see #29088
# Specify kwargs for the channel factory so that SMinion doesn't need to define an io_loop
# (The channel factories will set a default if the kwarg isn't passed)
factory_kwargs = {'timeout': timeout, 'safe': safe}
@ -517,9 +518,13 @@ class SMinion(MinionBase):
super(SMinion, self).__init__(opts)
# Clean out the proc directory (default /var/cache/salt/minion/proc)
if (self.opts.get('file_client', 'remote') == 'remote'
or self.opts.get('use_master_when_local', False)):
self.eval_master(self.opts, failed=True)
if (self.opts.get('file_client', 'remote') == 'remote' or
self.opts.get('use_master_when_local', False)):
# actually eval_master returns the future and we need to wait for it
self.io_loop = zmq.eventloop.ioloop.ZMQIOLoop()
far_future = self.eval_master(self.opts, failed=True)
self.io_loop.add_future(far_future, lambda _: self.io_loop.stop())
self.io_loop.start()
self.gen_modules(initial_load=True)
def gen_modules(self, initial_load=False):