diff --git a/oslo_messaging/_drivers/impl_rabbit.py b/oslo_messaging/_drivers/impl_rabbit.py index b9ff36353..263b2043c 100644 --- a/oslo_messaging/_drivers/impl_rabbit.py +++ b/oslo_messaging/_drivers/impl_rabbit.py @@ -581,7 +581,10 @@ class Connection(object): LOG.info(_LI("The broker has unblocked the connection")) def ensure_connection(self): - self.ensure(method=lambda: True) + # NOTE(sileht): we reset the channel and ensure + # the kombu underlying connection works + self._set_current_channel(None) + self.ensure(method=lambda: self.connection.connection) def ensure(self, method, retry=None, recoverable_error_callback=None, error_callback=None, @@ -732,7 +735,6 @@ class Connection(object): for tag, consumer in enumerate(self._consumers): consumer.cancel(tag=tag) except recoverable_errors: - self._set_current_channel(None) self.ensure_connection() self._consumers = [] diff --git a/oslo_messaging/tests/drivers/test_impl_rabbit.py b/oslo_messaging/tests/drivers/test_impl_rabbit.py index 52cbfe1cb..114fc52e1 100644 --- a/oslo_messaging/tests/drivers/test_impl_rabbit.py +++ b/oslo_messaging/tests/drivers/test_impl_rabbit.py @@ -896,6 +896,8 @@ class RpcKombuHATestCase(test_utils.BaseTestCase): self.useFixture(mockpatch.Patch( 'kombu.connection.Connection.connect', side_effect=self.kombu_connect)) + self.useFixture(mockpatch.Patch( + 'kombu.connection.Connection.connection')) self.useFixture(mockpatch.Patch( 'kombu.connection.Connection.channel'))