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):
handler = administration.AdministrationHandler
logging.info('Accept an admin %s' % dump(uuid))
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
klass = MasterNode
handler = secondary.SecondaryMasterHandler
......@@ -820,7 +823,7 @@ class Application(object):
elif node_type == protocol.CLIENT_NODE_TYPE:
# refuse any client before 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
klass = ClientNode
handler = client.ClientServiceHandler
......
......@@ -44,10 +44,8 @@ class ElectionHandler(MasterHandler):
continue
else:
node = app.nm.getNodeByServer(addr)
if node is None:
node = MasterNode(server = addr)
app.nm.add(node)
app.unconnected_master_node_set.add(addr)
# The master must be known
assert node is not None
if uuid is not None:
# If I don't know the UUID yet, believe what the peer
......@@ -168,10 +166,8 @@ class ClientElectionHandler(MasterHandler):
continue
else:
n = app.nm.getNodeByServer(address)
if n is None:
n = MasterNode(server=address)
app.nm.add(n)
app.unconnected_master_node_set.add(address)
# master node must be known
assert n is not None
if uuid is not None:
# If I don't know the UUID yet, believe what the peer
......@@ -232,14 +228,12 @@ class ServerElectionHandler(MasterHandler):
raise protocol.NotReadyError
node = app.nm.getNodeByServer(address)
if node is None:
node = MasterNode(server=address, uuid=uuid)
app.nm.add(node)
app.unconnected_master_node_set.add(address)
else:
# If this node is broken, reject it.
if node.getUUID() == uuid:
if node.getState() == BROKEN_STATE:
raise protocol.BrokenNodeDisallowedError
logging.error('unknown master node: %s' % (address, ))
raise protocol.ProtocolError('unknown master node')
# If this node is broken, reject it.
if node.getUUID() == uuid:
if node.getState() == BROKEN_STATE:
raise protocol.BrokenNodeDisallowedError
# supplied another uuid in case of conflict
while not app.isValidUUID(uuid, address):
......
......@@ -79,9 +79,8 @@ class PrimaryMasterHandler(MasterHandler):
continue
else:
n = app.nm.getNodeByServer(addr)
if n is None:
n = MasterNode(server = addr)
app.nm.add(n)
# master node must be known
assert n is not None
if uuid is not None:
# 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