Commit 59e7aafb authored by Vincent Pelletier's avatar Vincent Pelletier

Create masters as we are notified of their existence.

This increases cluster on-line flexibility, allowing new masters to be
added without needing a restart of all masters.
Downside is that more responsibility is pushed to cluster admins: they must
update node configurations so they contain enough master nodes to allow
them to join cluster after a restart.
parent a0ad2b86
...@@ -56,6 +56,8 @@ class PrimaryBootstrapHandler(AnswerBaseHandler): ...@@ -56,6 +56,8 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
# Register new master nodes. # Register new master nodes.
for address, uuid in known_master_list: for address, uuid in known_master_list:
n = app.nm.getByAddress(address) n = app.nm.getByAddress(address)
if n is None:
app.nm.createMaster(address=address)
if uuid is not None and n.getUUID() != uuid: if uuid is not None and n.getUUID() != uuid:
n.setUUID(uuid) n.setUUID(uuid)
......
...@@ -531,9 +531,6 @@ class Application(object): ...@@ -531,9 +531,6 @@ class Application(object):
handler = administration.AdministrationHandler(self) handler = administration.AdministrationHandler(self)
neo.lib.logging.info('Accept an admin %s' % (dump(uuid), )) neo.lib.logging.info('Accept an admin %s' % (dump(uuid), ))
elif node_type == NodeTypes.MASTER: elif node_type == NodeTypes.MASTER:
if node is None:
# unknown master, rejected
raise protocol.ProtocolError('Reject an unknown master node')
# always put other master in waiting state # always put other master in waiting state
node_ctor = self.nm.createMaster node_ctor = self.nm.createMaster
handler = secondary.SecondaryMasterHandler(self) handler = secondary.SecondaryMasterHandler(self)
......
...@@ -93,8 +93,8 @@ class ClientElectionHandler(MasterHandler): ...@@ -93,8 +93,8 @@ class ClientElectionHandler(MasterHandler):
# This is self. # This is self.
continue continue
n = app.nm.getByAddress(address) n = app.nm.getByAddress(address)
# master node must be known if n is None:
assert n is not None, 'Unknown master node: %s' % (address, ) n = app.nm.createMaster(address=address)
if uuid is not None: if uuid is not None:
# If I don't know the UUID yet, believe what the peer # If I don't know the UUID yet, believe what the peer
# told me at the moment. # told me at the moment.
...@@ -167,8 +167,7 @@ class ServerElectionHandler(MasterHandler): ...@@ -167,8 +167,7 @@ class ServerElectionHandler(MasterHandler):
raise NotReadyError raise NotReadyError
node = app.nm.getByAddress(address) node = app.nm.getByAddress(address)
if node is None: if node is None:
neo.lib.logging.error('unknown master node: %s' % (address, )) node = app.nm.createMaster(address=address)
raise ProtocolError('unknown master node')
# If this node is broken, reject it. # If this node is broken, reject it.
if node.getUUID() == uuid: if node.getUUID() == uuid:
if node.isBroken(): if node.isBroken():
......
...@@ -232,13 +232,6 @@ class MasterServerElectionTests(NeoUnitTestBase): ...@@ -232,13 +232,6 @@ class MasterServerElectionTests(NeoUnitTestBase):
self.election.requestIdentification, self.election.requestIdentification,
conn, NodeTypes.CLIENT, *args) conn, NodeTypes.CLIENT, *args)
def test_requestIdentification2(self):
""" A unknown master node request identification """
node, conn = self.identifyToMasterNode()
args = (node.getUUID(), ('127.0.0.1', 1000), self.app.name)
self.checkProtocolErrorRaised(self.election.requestIdentification,
conn, NodeTypes.MASTER, *args)
def test_requestIdentification3(self): def test_requestIdentification3(self):
""" A broken master node request identification """ """ A broken master node request identification """
node, conn = self.identifyToMasterNode() node, conn = self.identifyToMasterNode()
...@@ -302,18 +295,6 @@ class MasterServerElectionTests(NeoUnitTestBase): ...@@ -302,18 +295,6 @@ class MasterServerElectionTests(NeoUnitTestBase):
name=self.app.name name=self.app.name
) )
def testRequestIdentification2(self):
""" Check with an unknown master node """
conn = self.__getMaster(register=False)
self.checkProtocolErrorRaised(
self.election.requestIdentification,
conn=conn,
node_type=NodeTypes.MASTER,
uuid=conn.getUUID(),
address=conn.getAddress(),
name=self.app.name,
)
def testAnnouncePrimary1(self): def testAnnouncePrimary1(self):
""" check the wrong cases """ """ check the wrong cases """
announce = self.election.announcePrimary announce = self.election.announcePrimary
......
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