From a3b0b0240dc5ef048e9cce8d077552aed1961279 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 27 Sep 2018 10:30:30 -0400 Subject: [PATCH] Abort assimilation attempt on non-member cleanly If a confluent instance has forgotten the collective, more cleanly handle the situation, and abort the assimilation rather than assuming the peer should be leader, unless txcount specifically is called out as the reason. --- confluent_server/confluent/collective/manager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/collective/manager.py b/confluent_server/confluent/collective/manager.py index 735d9b1b..dae9279c 100644 --- a/confluent_server/confluent/collective/manager.py +++ b/confluent_server/confluent/collective/manager.py @@ -322,6 +322,11 @@ def handle_connection(connection, cert, request, local=False): if 'assimilate' == operation: drone = request['name'] droneinfo = cfm.get_collective_member(drone) + if not droneinfo: + tlvdata.send(connection, + {'error': 'Unrecognized leader, ' + 'redo invitation process'}) + return if not util.cert_matches(droneinfo['fingerprint'], cert): tlvdata.send(connection, {'error': 'Invalid certificate, ' @@ -432,7 +437,7 @@ def try_assimilate(drone): tlvdata.recv(remote) # the banner tlvdata.recv(remote) # authpassed... 0.. answer = tlvdata.recv(remote) - if answer and 'error' in answer: + if answer and 'txcount' in answer: connect_to_leader(None, None, leader=remote.getpeername()[0]) def get_leader(connection):