From c76149141fd7754b60bfb36a92221412620f6e8b Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sat, 10 Jul 2021 23:35:49 -0400 Subject: [PATCH] Only log ZK connections when persistent Prevents spam in the API logs. --- daemon-common/zkhandler.py | 7 ++++--- node-daemon/pvcnoded/Daemon.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/daemon-common/zkhandler.py b/daemon-common/zkhandler.py index cb6a8df7..5276fd40 100644 --- a/daemon-common/zkhandler.py +++ b/daemon-common/zkhandler.py @@ -140,13 +140,13 @@ class ZKHandler(object): """ try: self.zk_conn.start() - self.log('Connection to Zookeeper started', state='o') if persistent: + self.log('Connection to Zookeeper started', state='o') self.zk_conn.add_listener(self.listener) except Exception as 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 @@ -154,7 +154,8 @@ class ZKHandler(object): """ self.zk_conn.stop() 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 diff --git a/node-daemon/pvcnoded/Daemon.py b/node-daemon/pvcnoded/Daemon.py index a06346dc..60fb1f76 100644 --- a/node-daemon/pvcnoded/Daemon.py +++ b/node-daemon/pvcnoded/Daemon.py @@ -659,7 +659,7 @@ def update_schema(new_schema_version, stat, event=''): # Restart ourselves with the new schema logger.out('Reloading node daemon', state='s') try: - zkhandler.disconnect() + zkhandler.disconnect(persistent=True) del zkhandler except Exception: pass @@ -752,7 +752,7 @@ def cleanup(): # Close the Zookeeper connection try: - zkhandler.disconnect() + zkhandler.disconnect(persistent=True) del zkhandler except Exception: pass