Handle EtcdEventIndexCleared and EtcdWatcherCleared exceptions (#387)

If this case it doesn't make sense to retry, because it brings nothing
but produces a log of exceptions in the log...
This commit is contained in:
Alexander Kukushkin
2017-02-16 17:07:09 +01:00
committed by GitHub
parent 8aa173e79a
commit 1ed91a93c6
2 changed files with 5 additions and 0 deletions
+2
View File
@@ -530,6 +530,8 @@ class Etcd(AbstractDCS):
except etcd.EtcdWatchTimedOut:
self._client.http.clear()
return False
except (etcd.EtcdEventIndexCleared, etcd.EtcdWatcherCleared): # Watch failed
return True # leave the loop, because watch with the same parameters will fail anyway
except etcd.EtcdException:
logger.exception('watch')
+3
View File
@@ -61,6 +61,8 @@ def etcd_watch(self, key, index=None, timeout=None, recursive=None):
return etcd.EtcdResult('delete', {})
elif timeout == 10.0:
raise etcd.EtcdException
elif timeout == 20.0:
raise etcd.EtcdEventIndexCleared
def etcd_write(self, key, value, **kwargs):
@@ -307,6 +309,7 @@ class TestEtcd(unittest.TestCase):
self.etcd.watch(20729, 1.5)
self.etcd.watch(20729, 4.5)
with patch.object(AbstractDCS, 'watch', Mock()):
self.assertTrue(self.etcd.watch(20729, 19.5))
self.etcd.watch(20729, 9.5)
def test_other_exceptions(self):