summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Giusti <kgiusti@gmail.com>2018-11-05 16:02:06 -0500
committerKenneth Giusti <kgiusti@gmail.com>2018-11-05 16:02:06 -0500
commitfb3ab00d1d8778ff4460ec475124585f4febe042 (patch)
treeb5e66f1c3982b38e28d0acf5294d4ab442a0c51d
parent1a781bd6dca5f56593c530be9707e48bccff8e0c (diff)
downloadoslo-messaging-fb3ab00d1d8778ff4460ec475124585f4febe042.tar.gz
Use ensure_connection to prevent loss of connection error logs9.2.1
Change-Id: I31e3f83304c0780cfd380aa63ec2962c3c28ec78 Closes-Bug: #1801011
-rw-r--r--oslo_messaging/_drivers/impl_rabbit.py7
-rw-r--r--oslo_messaging/tests/drivers/test_impl_rabbit.py9
2 files changed, 12 insertions, 4 deletions
diff --git a/oslo_messaging/_drivers/impl_rabbit.py b/oslo_messaging/_drivers/impl_rabbit.py
index e2ac5e1..1d77cfd 100644
--- a/oslo_messaging/_drivers/impl_rabbit.py
+++ b/oslo_messaging/_drivers/impl_rabbit.py
@@ -637,8 +637,13 @@ class Connection(object):
def ensure_connection(self):
# NOTE(sileht): we reset the channel and ensure
# the kombu underlying connection works
+ def on_error(exc, interval):
+ LOG.error("Connection failed: %s (retrying in %s seconds)",
+ str(exc), interval)
+
self._set_current_channel(None)
- self.ensure(method=self.connection.connect)
+ self.connection.ensure_connection(errback=on_error)
+ self._set_current_channel(self.connection.channel())
self.set_transport_socket_timeout()
def ensure(self, method, retry=None,
diff --git a/oslo_messaging/tests/drivers/test_impl_rabbit.py b/oslo_messaging/tests/drivers/test_impl_rabbit.py
index cfbef74..b5f9e52 100644
--- a/oslo_messaging/tests/drivers/test_impl_rabbit.py
+++ b/oslo_messaging/tests/drivers/test_impl_rabbit.py
@@ -123,7 +123,8 @@ class TestRabbitDriverLoad(test_utils.BaseTestCase):
('rabbit+memory', dict(transport_url='kombu+memory:/'))
]
- @mock.patch('oslo_messaging._drivers.impl_rabbit.Connection.ensure')
+ @mock.patch('oslo_messaging._drivers.impl_rabbit.Connection'
+ '.ensure_connection')
@mock.patch('oslo_messaging._drivers.impl_rabbit.Connection.reset')
def test_driver_load(self, fake_ensure, fake_reset):
self.config(heartbeat_timeout_threshold=60,
@@ -155,7 +156,8 @@ class TestRabbitDriverLoadSSL(test_utils.BaseTestCase):
cert_reqs=ssl.CERT_REQUIRED))),
]
- @mock.patch('oslo_messaging._drivers.impl_rabbit.Connection.ensure')
+ @mock.patch('oslo_messaging._drivers.impl_rabbit.Connection'
+ '.ensure_connection')
@mock.patch('kombu.connection.Connection')
def test_driver_load(self, connection_klass, fake_ensure):
self.config(group="oslo_messaging_rabbit", **self.options)
@@ -406,7 +408,8 @@ class TestRabbitTransportURL(test_utils.BaseTestCase):
self.config(heartbeat_timeout_threshold=0,
group='oslo_messaging_rabbit')
- @mock.patch('oslo_messaging._drivers.impl_rabbit.Connection.ensure')
+ @mock.patch('oslo_messaging._drivers.impl_rabbit.Connection'
+ '.ensure_connection')
@mock.patch('oslo_messaging._drivers.impl_rabbit.Connection.reset')
def test_transport_url(self, fake_reset, fake_ensure):
transport = oslo_messaging.get_transport(self.conf, self.url)