]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Update ensure()/reconnect() to catch MessagingError
authorRussell Bryant <rbryant@redhat.com>
Wed, 9 Apr 2014 15:32:44 +0000 (11:32 -0400)
committerThomas Goirand <thomas@goirand.fr>
Mon, 9 Jun 2014 15:06:54 +0000 (23:06 +0800)
The error handling code that gets connections reset if necessary
caught ConnectionError. It really needs to catch MessagingError,
which ConnectionError inherits from. There are other types of
MessagingErrors that may occur, such as InternalError, and they need
to cause the connection to reset, as well.

This fix has already been merged into oslo.messaging.

--

Cherry-picked from oslo-incubator 234f64d608266f43d8856ff98c89ceba6699d752
See also https://bugzilla.redhat.com/show_bug.cgi?id=1086077

Closes-bug: #1303890
Change-Id: Ic5082b74a362ded8b35cbc75cf178fe6e0db62d0
(cherry picked from commit 9a830b370551019a4bd3a0c7504f48961e755bd4)

neutron/openstack/common/rpc/impl_qpid.py

index 6f2a3dc6c396634883aa2bf4b8d5c45edd06bf29..a7dcf29d3d128cb479a3b9b1fcc3cd26fd9fb368 100644 (file)
@@ -504,7 +504,7 @@ class Connection(object):
             if self.connection.opened():
                 try:
                     self.connection.close()
-                except qpid_exceptions.ConnectionError:
+                except qpid_exceptions.MessagingError:
                     pass
 
             broker = self.brokers[next(self.next_broker_indices)]
@@ -512,7 +512,7 @@ class Connection(object):
             try:
                 self.connection_create(broker)
                 self.connection.open()
-            except qpid_exceptions.ConnectionError as e:
+            except qpid_exceptions.MessagingError as e:
                 msg_dict = dict(e=e, delay=delay)
                 msg = _LE("Unable to connect to AMQP server: %(e)s. "
                           "Sleeping %(delay)s seconds") % msg_dict
@@ -540,7 +540,7 @@ class Connection(object):
             try:
                 return method(*args, **kwargs)
             except (qpid_exceptions.Empty,
-                    qpid_exceptions.ConnectionError) as e:
+                    qpid_exceptions.MessagingError) as e:
                 if error_callback:
                     error_callback(e)
                 self.reconnect()