Check if suspended callback is set before calling

The suspended callback is curently only used by the schedulers. Check if
the callback is set before calling it to avoid the following exception:

ERROR zuul.zk.base.ZooKeeperClient: Exception calling listener:
Traceback (most recent call last):
  File "/opt/zuul/lib/python3.11/site-packages/kazoo/protocol/connection.py", line 602, in _connect_attempt
    response = self._read_socket(read_timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/zuul/lib/python3.11/site-packages/kazoo/protocol/connection.py", line 435, in _read_socket
    header, buffer, offset = self._read_header(read_timeout)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/zuul/lib/python3.11/site-packages/kazoo/protocol/connection.py", line 225, in _read_header
    b = self._read(4, timeout)
        ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/zuul/lib/python3.11/site-packages/kazoo/protocol/connection.py", line 260, in _read
    raise ConnectionDropped('socket connection broken')
kazoo.exceptions.ConnectionDropped: socket connection broken
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/opt/zuul/lib/python3.11/site-packages/zuul/zk/__init__.py", line 98, in _connectionListener
    listener()
  File "/opt/zuul/lib/python3.11/site-packages/zuul/zk/nodepool.py", line 103, in _onSuspended
    self.connection_suspended_callback()
TypeError: 'NoneType' object is not callable

Change-Id: I5402096d0c7239f357d385841d1d886f97221ec2
This commit is contained in:
Simon Westphahl 2023-12-04 08:13:07 +01:00
parent 50e06b4e74
commit c522e5be02
No known key found for this signature in database
1 changed files with 2 additions and 1 deletions

View File

@ -100,7 +100,8 @@ class ZooKeeperNodepool(ZooKeeperBase):
self._node_tree = None
def _onSuspended(self):
self.connection_suspended_callback()
if self.connection_suspended_callback:
self.connection_suspended_callback()
def _nodePath(self, node):
return "%s/%s" % (self.NODES_ROOT, node)