2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-16 20:57:53 +00:00

Block some early startup problems in collective

This commit is contained in:
Jarrod Johnson 2018-05-11 14:49:46 -04:00
parent 173f1eaf7e
commit 3cc9ee1a17
2 changed files with 10 additions and 1 deletions

View File

@ -55,6 +55,9 @@ def connect_to_leader(cert=None, name=None, leader=None):
keydata = tlvdata.recv(remote)
if 'error' in keydata:
if 'leader' in keydata:
ldrc = cfm.get_collective_member_by_address(keydata['leader'])
if ldrc and ldrc['name'] == name:
raise Exception("Redirected to self")
return connect_to_leader(name=name, leader=keydata['leader'])
raise Exception(keydata['error'])
colldata = tlvdata.recv(remote)

View File

@ -446,13 +446,19 @@ def add_collective_member(name, address, fingerprint):
ConfigManager._bg_sync_to_file()
def list_collective():
if _cfgstore is None:
init()
return iter(_cfgstore.get('collective', ()))
def get_collective_member(name):
return _cfgstore['collective'][name]
if _cfgstore is None:
init()
return _cfgstore.get('collective', {}).get(name, None)
def get_collective_member_by_address(address):
if _cfgstore is None:
init()
for name in _cfgstore.get('collective', {}):
currdrone = _cfgstore['collective'][name]
if netutil.addresses_match(address, currdrone['address']):