mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-26 23:50:23 +00:00
Apply 1 second backoff if LIST failed (#1424)
It is mostly necessary to avoid flooding logs, but also help to prevent starvation of the main thread.
This commit is contained in:
@@ -106,7 +106,11 @@ class ObjectCache(Thread):
|
||||
self.start()
|
||||
|
||||
def _list(self):
|
||||
return self._func(_request_timeout=(self._retry.deadline, Timeout.DEFAULT_TIMEOUT))
|
||||
try:
|
||||
return self._func(_request_timeout=(self._retry.deadline, Timeout.DEFAULT_TIMEOUT))
|
||||
except Exception:
|
||||
time.sleep(1)
|
||||
raise
|
||||
|
||||
def _watch(self, resource_version):
|
||||
return self._func(_request_timeout=(self._retry.deadline, Timeout.DEFAULT_TIMEOUT),
|
||||
|
||||
@@ -174,3 +174,8 @@ class TestCacheBuilder(unittest.TestCase):
|
||||
@patch('patroni.dcs.kubernetes.ObjectCache._build_cache', Mock(side_effect=Exception))
|
||||
def test_run(self):
|
||||
self.assertRaises(SleepException, self.k._pods.run)
|
||||
|
||||
@patch('time.sleep', Mock())
|
||||
def test__list(self):
|
||||
self.k._pods._func = Mock(side_effect=Exception)
|
||||
self.assertRaises(Exception, self.k._pods._list)
|
||||
|
||||
Reference in New Issue
Block a user