From 5abaddfe638cf8c1d403d6a8788b782eeaf519d6 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 4 May 2018 12:19:45 -0400 Subject: [PATCH] Clear configuration prior to sync --- confluent_server/confluent/collective/manager.py | 4 ++++ confluent_server/confluent/config/configmanager.py | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/confluent_server/confluent/collective/manager.py b/confluent_server/confluent/collective/manager.py index 422980fe..1c66158a 100644 --- a/confluent_server/confluent/collective/manager.py +++ b/confluent_server/confluent/collective/manager.py @@ -59,7 +59,11 @@ def connect_to_leader(cert=None, name=None): if not ndata: raise Exception("Error doing initial DB transfer") dbjson += ndata + cfm.clear_configuration() cfm._restore_keys(keydata, None) + for c in colldata: + cfm.add_collective_member(c, colldata[c]['address'], + colldata[c]['fingerprint']) cfm._cfgstore['collective'] = colldata for globvar in globaldata: cfm.set_global(globvar, globaldata[globvar]) diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index b49140c6..bd787e97 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -374,6 +374,17 @@ cfgstreams = {} def register_config_listener(name, listener): cfgstreams[listener] = name +def clear_configuration(): + global _cfgstore + _cfgstore = {} + todelete = _config_areas + ('globals', 'collective') + for cfg in todelete: + try: + os.remove(os.path.join(ConfigManager._cfgdir, cfg)) + except OSError as oe: + pass + + def add_collective_member(name, address, fingerprint): try: name = name.encode('utf-8')