Commit fa63d856 authored by Julien Muchembled's avatar Julien Muchembled

Fix handling of -m/--masters arg

For the master, the purpose of -m/--masters is to specify addresses
of other master nodes, since its own address is already known via
-b/--bind. Therefore, an empty value for -m/--masters is valid.
The user remains free to repeat the -b value in -m.

More generally, a node may choose to only specify master addresses
via -D/--dynamic-master-list, so the check that at least one master
address is specified is moved where the NodeManager is expected to be
parent c34d332f
......@@ -138,8 +138,7 @@ class Application(BaseApplication, Monitor):
def __init__(self, config):
config.get('ssl'), config.get('dynamic_master_list'))
for address in config['masters']:
self.nm.createMasters(config['masters']) = config['cluster']
self.server = config['bind']
......@@ -57,8 +57,9 @@ class BaseApplication(object):
_('s', 'section', default=section,
help='specify a configuration section')
_('c', 'cluster', required=True, help='the cluster name')
_('m', 'masters', default=masters, parse=util.parseMasterList,
help='master node list')
_('m', 'masters', parse=util.parseMasterList,
help='space-separated list of master node addresses',
**{'default': masters} if masters else {'type': lambda x: x or ''})
_('b', 'bind', default=bind,
parse=lambda x: util.parseNodeAddress(x, 0),
help='the local address to bind to')
......@@ -393,6 +393,12 @@ class NodeManager(EventQueue):
raise NotReadyError('unknown by master')
return node
def createMasters(self, master_nodes):
for address in master_nodes:
if not self.getMasterList():
raise ValueError("At least one master must be defined")
def _createNode(self, klass, address=None, uuid=None, **kw):
by_address = self.getByAddress(address)
by_uuid = self.getByUUID(uuid)
......@@ -53,10 +53,7 @@ class ThreadedApplication(BaseApplication): = name
self.dispatcher = Dispatcher()
self.master_conn = None
# load master node list
for address in master_nodes:
# Internal attribute distinct between thread
self._thread_container = ThreadContainer()
......@@ -158,7 +158,6 @@ def parseNodeAddress(address, port_opt=None):
return socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)[0][4][:2]
def parseMasterList(masters):
assert masters, 'At least one master must be defined'
return map(parseNodeAddress, masters.split())
......@@ -108,7 +108,7 @@ class Application(BaseApplication):
self.storage_ready_dict = {}
self.storage_starting_set = set()
for master_address in config['masters']:
for master_address in config.get('masters', ()):
self._node = self.nm.createMaster(address=self.server,
......@@ -72,8 +72,7 @@ class BackupApplication(object): = weakref.proxy(app) = name
self.nm = NodeManager()
for master_address in master_addresses:
em = property(lambda self:
ssl = property(lambda self:
......@@ -98,10 +98,7 @@ class Application(BaseApplication):
self.disable_drop_partitions = config.get('disable_drop_partitions',
# load master nodes
for master_address in config['masters']:
# set the bind address
self.server = config['bind']
......@@ -66,8 +66,7 @@ class StressApplication(AdminApplication):
def __init__(self, ssl, master_nodes):
BaseApplication.__init__(self, ssl)
for address in master_nodes:
self.nm.createMasters(master_nodes) = None
self.master_event_handler = Handler(self)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment