From 209c985420b5b437b8afc9dfedfabf7366a01944 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Mon, 14 Sep 2015 11:45:00 +0200 Subject: [PATCH] get_node and get_children should catch only NoNodeError exception. All other exceptions are needed to have retry functionality working correctly. --- patroni/zookeeper.py | 10 ++-------- tests/test_zookeeper.py | 6 ------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/patroni/zookeeper.py b/patroni/zookeeper.py index 5f9625ac..f2ef2e99 100644 --- a/patroni/zookeeper.py +++ b/patroni/zookeeper.py @@ -110,10 +110,7 @@ class ZooKeeper(AbstractDCS): try: return self.client.get(key, watch) except NoNodeError: - pass - except: - logger.exception('get_node') - return None + return None @staticmethod def member(name, value, znode): @@ -124,10 +121,7 @@ class ZooKeeper(AbstractDCS): try: return self.client.get_children(key, watch) except NoNodeError: - pass - except: - logger.exception('get_children') - return [] + return [] def load_members(self): members = [] diff --git a/tests/test_zookeeper.py b/tests/test_zookeeper.py index 19435c6e..4b31bad2 100644 --- a/tests/test_zookeeper.py +++ b/tests/test_zookeeper.py @@ -58,8 +58,6 @@ class MockKazooClient: def get(self, path, watch=None): if path == '/no_node': raise NoNodeError - elif path == '/other_exception': - raise Exception() elif '/members/' in path: return ( 'postgres://repuser:rep-pass@localhost:5434/postgres?application_name=http://127.0.0.1:8009/patroni', @@ -77,8 +75,6 @@ class MockKazooClient: def get_children(self, path, watch=None, include_data=False): if path == '/no_node': raise NoNodeError - elif path == '/other_exception': - raise Exception() elif path in ['/service/bla/', '/service/test/']: return ['initialize', 'leader', 'members', 'optime'] return ['foo', 'bar', 'buzz'] @@ -142,11 +138,9 @@ class TestZooKeeper(unittest.TestCase): def test_get_node(self): self.assertIsNone(self.zk.get_node('/no_node')) - self.assertIsNone(self.zk.get_node('/other_exception')) def test_get_children(self): self.assertListEqual(self.zk.get_children('/no_node'), []) - self.assertListEqual(self.zk.get_children('/other_exception'), []) def test__inner_load_cluster(self): self.zk._base_path = self.zk._base_path.replace('test', 'bla')