Commit 0c97b789 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Don't accept master nodes as secondary if they are not in the configuration

file. New masters will be registered by an admin and their config updated to
ensure no more than one master could run concurrently when they restart without
known each other.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1170 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent e66209ba
...@@ -813,6 +813,9 @@ class Application(object): ...@@ -813,6 +813,9 @@ class Application(object):
handler = administration.AdministrationHandler handler = administration.AdministrationHandler
logging.info('Accept an admin %s' % dump(uuid)) logging.info('Accept an admin %s' % dump(uuid))
elif node_type == protocol.MASTER_NODE_TYPE: elif node_type == protocol.MASTER_NODE_TYPE:
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
klass = MasterNode klass = MasterNode
handler = secondary.SecondaryMasterHandler handler = secondary.SecondaryMasterHandler
...@@ -820,7 +823,7 @@ class Application(object): ...@@ -820,7 +823,7 @@ class Application(object):
elif node_type == protocol.CLIENT_NODE_TYPE: elif node_type == protocol.CLIENT_NODE_TYPE:
# refuse any client before running # refuse any client before running
if self.cluster_state != protocol.RUNNING: if self.cluster_state != protocol.RUNNING:
logging.info('reject a connection from a client') logging.info('Reject a connection from a client')
raise protocol.NotReadyError raise protocol.NotReadyError
klass = ClientNode klass = ClientNode
handler = client.ClientServiceHandler handler = client.ClientServiceHandler
......
...@@ -44,10 +44,8 @@ class ElectionHandler(MasterHandler): ...@@ -44,10 +44,8 @@ class ElectionHandler(MasterHandler):
continue continue
else: else:
node = app.nm.getNodeByServer(addr) node = app.nm.getNodeByServer(addr)
if node is None: # The master must be known
node = MasterNode(server = addr) assert node is not None
app.nm.add(node)
app.unconnected_master_node_set.add(addr)
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
...@@ -168,10 +166,8 @@ class ClientElectionHandler(MasterHandler): ...@@ -168,10 +166,8 @@ class ClientElectionHandler(MasterHandler):
continue continue
else: else:
n = app.nm.getNodeByServer(address) n = app.nm.getNodeByServer(address)
if n is None: # master node must be known
n = MasterNode(server=address) assert n is not None
app.nm.add(n)
app.unconnected_master_node_set.add(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
...@@ -232,14 +228,12 @@ class ServerElectionHandler(MasterHandler): ...@@ -232,14 +228,12 @@ class ServerElectionHandler(MasterHandler):
raise protocol.NotReadyError raise protocol.NotReadyError
node = app.nm.getNodeByServer(address) node = app.nm.getNodeByServer(address)
if node is None: if node is None:
node = MasterNode(server=address, uuid=uuid) logging.error('unknown master node: %s' % (address, ))
app.nm.add(node) raise protocol.ProtocolError('unknown master node')
app.unconnected_master_node_set.add(address) # If this node is broken, reject it.
else: if node.getUUID() == uuid:
# If this node is broken, reject it. if node.getState() == BROKEN_STATE:
if node.getUUID() == uuid: raise protocol.BrokenNodeDisallowedError
if node.getState() == BROKEN_STATE:
raise protocol.BrokenNodeDisallowedError
# supplied another uuid in case of conflict # supplied another uuid in case of conflict
while not app.isValidUUID(uuid, address): while not app.isValidUUID(uuid, address):
......
...@@ -79,9 +79,8 @@ class PrimaryMasterHandler(MasterHandler): ...@@ -79,9 +79,8 @@ class PrimaryMasterHandler(MasterHandler):
continue continue
else: else:
n = app.nm.getNodeByServer(addr) n = app.nm.getNodeByServer(addr)
if n is None: # master node must be known
n = MasterNode(server = addr) assert n is not None
app.nm.add(n)
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
......
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