From 661bdd7f41d1e253e76c9d516019eb6aafe90f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Thu, 18 Jun 2020 13:04:17 +0200 Subject: [PATCH] Drop a python 2 exception management Previously (when python 2 was supported) we introduced some specific exception management to detect connections issues when a rabbitmq cluster node disappearing. The original issue was that a ConnectionRefusedError is thrown and not managed by oslo.messaging to detect heartbeat issue and call ensure_connection for switching the connection destination (cluster node). `ConnectionRefusedError` is only a python 3 exception [2]. Now that we only support python 3 we don't need to continue to wrap/emulate this kind of exceptions (ConnectionRefusedError) [2] and so we can drop the python 2 compatibility code to only support python 3 code. [1] https://github.com/openstack/oslo.messaging/commit/9d8b1430e5c081b081c0e3c0b5f12f744dc7809d [2] https://docs.python.org/3/library/exceptions.html#ConnectionRefusedError Change-Id: I4c459d8c947dac213a1866c0d37e8f3d547aa82e --- oslo_messaging/_drivers/impl_rabbit.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/oslo_messaging/_drivers/impl_rabbit.py b/oslo_messaging/_drivers/impl_rabbit.py index c5c39704b..f6ddf8fc2 100644 --- a/oslo_messaging/_drivers/impl_rabbit.py +++ b/oslo_messaging/_drivers/impl_rabbit.py @@ -975,13 +975,6 @@ 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(): @@ -1008,7 +1001,7 @@ class Connection(object): # ensure_connection for switching the # connection destination. except (socket.timeout, - ConnectRefuseError, + ConnectionRefusedError, OSError, kombu.exceptions.OperationalError) as exc: LOG.info("A recoverable connection/channel error "