Use ensure_connection to prevent loss of connection error logs

Change-Id: I31e3f83304c0780cfd380aa63ec2962c3c28ec78
Closes-Bug: #1801011
This commit is contained in:
Kenneth Giusti 2018-11-05 16:02:06 -05:00
parent 1a781bd6dc
commit fb3ab00d1d
2 changed files with 12 additions and 4 deletions

View File

@ -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,

View File

@ -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)