Merge pull request #31760 from sakateka/fix_master_switch

SMinion need wait future from eval_master
This commit is contained in:
Mike Place 2016-03-24 16:08:56 -06:00
commit b23a08f3f4

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,11 @@ 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()
self.io_loop.run_sync(lambda: self.eval_master(self.opts, failed=True))
self.gen_modules(initial_load=True)
def gen_modules(self, initial_load=False):