From 02003c562638c67c9985ec9faa53bbada39b96d8 Mon Sep 17 00:00:00 2001 From: Simon Westphahl Date: Tue, 5 Oct 2021 10:56:23 +0200 Subject: Only retry ZK operations for Kazoo exceptions The current ZKObject implementations retries indefinitely in case of an exception during delete, _load or _save. In case of some non-ZK related exeception (e.g. when deserializing the data) it doesn't make sense to retry as it will probably always fail. Change-Id: I7e06c6ba9c821ccbd25cdb1beab6539474ca9e13 --- zuul/zk/zkobject.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'zuul/zk/zkobject.py') diff --git a/zuul/zk/zkobject.py b/zuul/zk/zkobject.py index 9534aa8d0..58aba7f14 100644 --- a/zuul/zk/zkobject.py +++ b/zuul/zk/zkobject.py @@ -16,7 +16,7 @@ import json import time import contextlib -from kazoo.exceptions import ZookeeperError +from kazoo.exceptions import KazooException, ZookeeperError class ZKContext: @@ -137,7 +137,7 @@ class ZKObject: # retryable. Connection errors are KazooExceptions so # they aren't caught here and we will retry. raise - except Exception: + except KazooException: context.log.exception( "Exception deleting ZKObject %s, will retry", self) time.sleep(self._retry_interval) @@ -165,7 +165,7 @@ class ZKObject: # retryable. Connection errors are KazooExceptions so # they aren't caught here and we will retry. raise - except Exception: + except KazooException: context.log.exception( "Exception loading ZKObject %s, will retry", self) time.sleep(5) @@ -189,7 +189,7 @@ class ZKObject: # retryable. Connection errors are KazooExceptions so # they aren't caught here and we will retry. raise - except Exception: + except KazooException: context.log.exception( "Exception saving ZKObject %s, will retry", self) time.sleep(self._retry_interval) -- cgit v1.2.1