diff options
author | Zuul <zuul@review.opendev.org> | 2019-05-20 21:05:57 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2019-05-20 21:05:57 +0000 |
commit | fe0ac3195ef1dcb1b481f0f5cf6ff2b55ca6056d (patch) | |
tree | b4cca01d3be3164c313ad33c5cf1c0eb041fa000 | |
parent | 4f467fbd73092aadda8b42e517bb60a4782064ae (diff) | |
parent | 9d8b1430e5c081b081c0e3c0b5f12f744dc7809d (diff) | |
download | oslo-messaging-fe0ac3195ef1dcb1b481f0f5cf6ff2b55ca6056d.tar.gz |
Merge "Fix switch connection destination when a rabbitmq cluster node disappear"9.7.0
-rw-r--r-- | oslo_messaging/_drivers/impl_rabbit.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/oslo_messaging/_drivers/impl_rabbit.py b/oslo_messaging/_drivers/impl_rabbit.py index 817e7be..6158300 100644 --- a/oslo_messaging/_drivers/impl_rabbit.py +++ b/oslo_messaging/_drivers/impl_rabbit.py @@ -913,6 +913,14 @@ class Connection(object): def _heartbeat_thread_job(self): """Thread that maintains inactive connections """ + # NOTE(hberaud): Python2 doesn't have ConnectionRefusedError + # defined so to switch connections destination on failure + # with python2 and python3 we need to wrapp adapt connection refused + try: + ConnectRefuseError = ConnectionRefusedError + except NameError: + ConnectRefuseError = socket.error + while not self._heartbeat_exit_event.is_set(): with self._connection_lock.for_heartbeat(): @@ -929,7 +937,17 @@ class Connection(object): self.connection.drain_events(timeout=0.001) except socket.timeout: pass + # NOTE(hberaud): In a clustered rabbitmq when + # a node disappears, we get a ConnectionRefusedError + # because the socket get disconnected. + # The socket access yields a OSError because the heartbeat + # tries to reach an unreachable host (No route to host). + # Catch these exceptions to ensure that we call + # ensure_connection for switching the + # connection destination. except (socket.timeout, + ConnectRefuseError, + OSError, kombu.exceptions.OperationalError) as exc: LOG.info("A recoverable connection/channel error " "occurred, trying to reconnect: %s", exc) |