Only log ZK connections when persistent

Prevents spam in the API logs.
This commit is contained in:
Joshua Boniface 2021-07-10 23:35:49 -04:00
parent f00c4d07f4
commit c76149141f
2 changed files with 6 additions and 5 deletions

View File

@ -140,13 +140,13 @@ class ZKHandler(object):
""" """
try: try:
self.zk_conn.start() self.zk_conn.start()
self.log('Connection to Zookeeper started', state='o')
if persistent: if persistent:
self.log('Connection to Zookeeper started', state='o')
self.zk_conn.add_listener(self.listener) self.zk_conn.add_listener(self.listener)
except Exception as e: except Exception as e:
raise ZKConnectionException(self, e) raise ZKConnectionException(self, e)
def disconnect(self): def disconnect(self, persistent=False):
""" """
Stop and close the zk_conn object and disconnect from the cluster Stop and close the zk_conn object and disconnect from the cluster
@ -154,7 +154,8 @@ class ZKHandler(object):
""" """
self.zk_conn.stop() self.zk_conn.stop()
self.zk_conn.close() self.zk_conn.close()
self.log('Connection to Zookeeper terminated', state='o') if persistent:
self.log('Connection to Zookeeper terminated', state='o')
# #
# Schema helper actions # Schema helper actions

View File

@ -659,7 +659,7 @@ def update_schema(new_schema_version, stat, event=''):
# Restart ourselves with the new schema # Restart ourselves with the new schema
logger.out('Reloading node daemon', state='s') logger.out('Reloading node daemon', state='s')
try: try:
zkhandler.disconnect() zkhandler.disconnect(persistent=True)
del zkhandler del zkhandler
except Exception: except Exception:
pass pass
@ -752,7 +752,7 @@ def cleanup():
# Close the Zookeeper connection # Close the Zookeeper connection
try: try:
zkhandler.disconnect() zkhandler.disconnect(persistent=True)
del zkhandler del zkhandler
except Exception: except Exception:
pass pass