Merge pull request #29814 from basepi/multi-master.windows.29396

[2015.8][Windows] Fix multi-master on windows
This commit is contained in:
Mike Place 2015-12-18 10:16:52 -07:00
commit 7eefaac58a
3 changed files with 38 additions and 2 deletions

View file

@ -63,6 +63,20 @@ connected masters:
Now the minion can be safely restarted.
.. note::
If the ipc_mode for the minion is set to TCP (default in Windows), then
each minion in the multi-minion setup (one per master) needs its own
tcp_pub_port and tcp_pull_port.
If these settings are left as the default 4510/4511, each minion object
will receive a port 2 higher than the previous. Thus the first minion will
get 4510/4511, the second will get 4512/4513, and so on. If these port
decisions are unacceptable, you must configure tcp_pub_port and
tcp_pull_port with lists of ports for each master. The length of these
lists should match the number of masters, and there should not be overlap
in the lists.
Now the minions will check into the original master and also check into the new
redundant master. Both masters are first-class and have rights to the minions.

View file

@ -100,7 +100,8 @@ from salt.exceptions import (
SaltInvocationError,
SaltReqTimeoutError,
SaltClientError,
SaltSystemExit
SaltSystemExit,
SaltException,
)
@ -617,12 +618,33 @@ class MultiMinion(MinionBase):
log.error(
'Attempting to start a multimaster system with one master')
sys.exit(salt.defaults.exitcodes.EX_GENERIC)
# Check that for tcp ipc_mode that we have either default ports or
# lists of ports
if self.opts.get('ipc_mode') == 'tcp' and (
(not isinstance(self.opts['tcp_pub_port'], list) and
self.opts['tcp_pub_port'] != 4510) or
(not isinstance(self.opts['tcp_pull_port'], list) and
self.opts['tcp_pull_port'] != 4511)
):
raise SaltException('For multi-master, tcp_(pub/pull)_port '
'settings must be lists of ports, or the '
'default 4510 and 4511')
masternumber = 0
for master in set(self.opts['master']):
s_opts = copy.deepcopy(self.opts)
s_opts['master'] = master
s_opts['multimaster'] = True
s_opts['auth_timeout'] = self.MINION_CONNECT_TIMEOUT
if self.opts.get('ipc_mode') == 'tcp':
# If one is a list, we can assume both are, because of check above
if isinstance(self.opts['tcp_pub_port'], list):
s_opts['tcp_pub_port'] = self.opts['tcp_pub_port'][masternumber]
s_opts['tcp_pull_port'] = self.opts['tcp_pull_port'][masternumber]
else:
s_opts['tcp_pub_port'] = self.opts['tcp_pub_port'] + (masternumber * 2)
s_opts['tcp_pull_port'] = self.opts['tcp_pull_port'] + (masternumber * 2)
self.io_loop.spawn_callback(self._connect_minion, s_opts)
masternumber += 1
@tornado.gen.coroutine
def _connect_minion(self, opts):

View file

@ -184,7 +184,7 @@ class SaltEvent(object):
self.opts = opts
if sock_dir is None:
sock_dir = opts.get('sock_dir', None)
if salt.utils.is_windows() and not hasattr(opts, 'ipc_mode'):
if salt.utils.is_windows() and 'ipc_mode' not in opts:
opts['ipc_mode'] = 'tcp'
self.puburi, self.pulluri = self.__load_uri(sock_dir, node)
self.pending_tags = []