summaryrefslogtreecommitdiff
path: root/zuul/zk/zkobject.py
diff options
context:
space:
mode:
authorJames E. Blair <jim@acmegating.com>2021-11-10 14:24:13 -0800
committerJames E. Blair <jim@acmegating.com>2021-11-10 15:31:01 -0800
commit6afde1e80a29074a8859a66e37f82df43de192b2 (patch)
treee644aef85b8fb0907a95553c3ff5545d35860c50 /zuul/zk/zkobject.py
parent3b409abf737ae41110fe61ad8e00b89f67ae2f28 (diff)
downloadzuul-6afde1e80a29074a8859a66e37f82df43de192b2.tar.gz
Identify the object in ZKObject (de)serialization errors
In case we raise an exception when serializing or deserializing, log the object so there is a clue about what object (which may be deep in a pipeline object tree) caused the issue. Change-Id: Ibf345f5bee9d923fee56d0f8b24058f0480b9166
Diffstat (limited to 'zuul/zk/zkobject.py')
-rw-r--r--zuul/zk/zkobject.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/zuul/zk/zkobject.py b/zuul/zk/zkobject.py
index 89c91a67b..20190e9ef 100644
--- a/zuul/zk/zkobject.py
+++ b/zuul/zk/zkobject.py
@@ -187,12 +187,25 @@ class ZKObject:
context.log.exception(
"Exception loading ZKObject %s, will retry", self)
time.sleep(5)
+ except Exception:
+ # A higher level must handle this exception, but log
+ # ourself here so we know what object triggered it.
+ context.log.error(
+ "Exception loading ZKObject %s", self)
+ raise
raise Exception("ZooKeeper session or lock not valid")
def _save(self, context, create=False):
if isinstance(context, LocalZKContext):
return
- data = self.serialize()
+ try:
+ data = self.serialize()
+ except Exception:
+ # A higher level must handle this exception, but log
+ # ourself here so we know what object triggered it.
+ context.log.error(
+ "Exception serializing ZKObject %s", self)
+ raise
path = self.getPath()
while context.sessionIsValid():
try:
@@ -254,6 +267,10 @@ class ShardedZKObject(ZKObject):
"Exception loading ZKObject %s, will retry", self)
time.sleep(5)
except Exception as exc:
+ # A higher level must handle this exception, but log
+ # ourself here so we know what object triggered it.
+ context.log.error(
+ "Exception loading ZKObject %s", self)
self.delete(context)
raise InvalidObjectError from exc
raise Exception("ZooKeeper session or lock not valid")
@@ -261,7 +278,14 @@ class ShardedZKObject(ZKObject):
def _save(self, context, create=False):
if isinstance(context, LocalZKContext):
return
- data = self.serialize()
+ try:
+ data = self.serialize()
+ except Exception:
+ # A higher level must handle this exception, but log
+ # ourself here so we know what object triggered it.
+ context.log.error(
+ "Exception serializing ZKObject %s", self)
+ raise
path = self.getPath()
while context.sessionIsValid():
try: