get_node and get_children should catch only NoNodeError exception.

All other exceptions are needed to have retry functionality working
correctly.
This commit is contained in:
Alexander Kukushkin
2015-09-14 11:45:00 +02:00
parent f494d2ce64
commit 209c985420
2 changed files with 2 additions and 14 deletions
+2 -8
View File
@@ -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 = []
-6
View File
@@ -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')