diff --git a/confluent_server/confluent/collective/manager.py b/confluent_server/confluent/collective/manager.py index 90a5e55b..ece48b14 100644 --- a/confluent_server/confluent/collective/manager.py +++ b/confluent_server/confluent/collective/manager.py @@ -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) diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index 4b34151d..59c98d68 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -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']):