Catch only MessageDeliveryFailure exceptions

There was a todo left to only catch MessageDeliveryFailure exceptions
once they were being propagated properly; the bug related to that [1]
has been closed and the fix is merged [2].  So we can catch only the
correct error and eliminate the TODO.

TrivialFix

[1] https://bugs.launchpad.net/neutron/+bug/1705351
[2] https://review.openstack.org/486706

Change-Id: I1201ee150709b84e6f4b2fa4b108da9ea28983a3
This commit is contained in:
Nate Johnston 2019-02-15 18:02:26 -05:00
parent 3133add2c9
commit ca8026b5c1
2 changed files with 4 additions and 6 deletions

View File

@ -25,6 +25,7 @@ from neutron_lib.utils import runtime
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging
from oslo_messaging import exceptions as oslomsg_exc
from oslo_messaging.rpc import dispatcher
from oslo_messaging import serializer as om_serializer
from oslo_service import service
@ -104,11 +105,7 @@ class _ContextWrapper(object):
def cast(self, ctxt, method, **kwargs):
try:
self._original_context.cast(ctxt, method, **kwargs)
except Exception as e:
# TODO(kevinbenton): make catch specific to missing exchange once
# bug/1705351 is resolved on the oslo.messaging side; if
# oslo.messaging auto-creates the exchange, then just remove the
# code completely
except oslomsg_exc.MessageDeliveryFailure as e:
LOG.debug("Ignored exception during cast: %s", str(e))

View File

@ -15,6 +15,7 @@ import mock
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_messaging import conffixture as messaging_conffixture
from oslo_messaging import exceptions as oslomsg_exc
from oslo_messaging.rpc import dispatcher
import testtools
@ -445,7 +446,7 @@ class CastExceptionTestCase(base.BaseTestCase):
self.addCleanup(rpc.cleanup)
rpc.init(CONF)
rpc.TRANSPORT = mock.MagicMock()
rpc.TRANSPORT._send.side_effect = Exception
rpc.TRANSPORT._send.side_effect = oslomsg_exc.MessageDeliveryFailure
target = messaging.Target(version='1.0', topic='testing')
self.client = rpc.get_client(target)
self.cast_context = mock.Mock()