Commit fbcf9c50 authored by Julien Muchembled's avatar Julien Muchembled

master: fix identification of unknown masters

This fixes the following crash:

  Traceback (most recent call last):
    ...
    File "neo/master/handlers/identification.py", line 94, in requestIdentification
      uuid = app.getNewUUID(uuid, address, node_type)
    File "neo/master/app.py", line 449, in getNewUUID
      assert uuid != self.uuid
  AssertionError
parent 29e8323c
......@@ -49,7 +49,10 @@ class IdentificationHandler(EventHandler):
node = uuid = None
break
else:
node.setAddress(address)
if node is app._node:
node = None
else:
node.setAddress(address)
break
# Id conflict for a storage node.
else:
......
......@@ -321,10 +321,10 @@ class ServerNode(Node):
if not address:
address = self.newAddress()
if cluster is None:
master_nodes = kw.get('master_nodes', ())
master_nodes = ()
name = kw.get('name', 'test')
else:
master_nodes = kw.get('master_nodes', cluster.master_nodes)
master_nodes = cluster.master_nodes
name = kw.get('name', cluster.name)
port = address[1]
if address is not BIND:
......
......@@ -2319,6 +2319,21 @@ class Test(NEOThreadedTest):
self.assertTrue(m0.primary)
self.assertFalse(m2.primary)
@with_cluster(start_cluster=0, master_count=2)
def testIdentifyUnknownMaster(self, cluster):
m0, m1 = cluster.master_list
cluster.master_nodes = ()
m0.resetNode()
cluster.start(master_list=(m0,))
m1.start()
self.tic()
self.assertEqual(cluster.neoctl.getClusterState(),
ClusterStates.RUNNING)
self.assertTrue(m0.primary)
self.assertTrue(m0.is_alive())
self.assertFalse(m1.primary)
self.assertTrue(m1.is_alive())
if __name__ == "__main__":
unittest.main()
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