From 7df200ac4464f58cc5df5cce1faefc975c7b18ec Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Tue, 9 Jul 2019 19:14:53 -0400 Subject: [PATCH] Improve ZK connection loss handling --- node-daemon/pvcd/Daemon.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/node-daemon/pvcd/Daemon.py b/node-daemon/pvcd/Daemon.py index 9a57fb6b..5354f4ba 100644 --- a/node-daemon/pvcd/Daemon.py +++ b/node-daemon/pvcd/Daemon.py @@ -468,13 +468,18 @@ def zk_listener(state): logger.out('Connection to Zookeeper lost; retrying', state='w') while True: + time.sleep(0.5) + _zk_conn = kazoo.client.KazooClient(hosts=config['coordinators']) try: _zk_conn.start() - zk_conn = _zk_conn - break except: - time.sleep(1) + del _zk_conn + continue + + zk_conn = _zk_conn + break + zk_conn.add_listener(zk_listener) ###############################################################################