Description
===========
If policy allow attaching external network, Attach a 'public' network return 500.
Steps to reproduce
==================
1. Run devstack with default configuration.
2. Add policy.json to allow attaching external network.
3. Source demo credential
4. Create an instance and wait for the instance to become active.
5. Attach the instance with the 'public' network.
$ nova interface-attach --net-id 2b7e8a86-c5c6-4396-84bc-14cdc741e033 test
ERROR (ClientException): Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
<type 'exceptions.TypeError'> (HTTP 500) (Request-ID: req-3e353c62-a356-4d7d-bd73-28cf4406e447)
Expected result
===============
Nova should return 4xx response
Actual result
=============
Nova returned 500 response
Environment
===========
Devstack with master
Logs & Configs
==============
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server [None req-3e125907-0419-418a-a03c-154b99e97610 demo demo] Exception during message handling: TypeError: <class 'neutronclient.common.exceptions.Forbidden'> can't be encoded
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server Traceback (most recent call last):
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/server.py", line 160, in _process_incoming
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server res = self.dispatcher.dispatch(message)
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 222, in dispatch
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server return self._do_dispatch(endpoint, method, ctxt, args)
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 192, in _do_dispatch
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server result = func(ctxt, **new_args)
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/opt/stack/nova/nova/exception_wrapper.py", line 76, in wrapped
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server function_name, call_dict, binary)
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 220, in __exit__
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server self.force_reraise()
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 196, in force_reraise
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server six.reraise(self.type_, self.value, self.tb)
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/opt/stack/nova/nova/exception_wrapper.py", line 67, in wrapped
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server return f(self, context, *args, **kw)
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/opt/stack/nova/nova/compute/manager.py", line 217, in decorated_function
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server kwargs['instance'], e, sys.exc_info())
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/opt/stack/nova/nova/compute/utils.py", line 99, in add_instance_fault_from_exc
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server fault_obj.update(exception_to_dict(fault, message=fault_message))
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/opt/stack/nova/nova/compute/utils.py", line 76, in exception_to_dict
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server u_message = utils.safe_truncate(message, 255)
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/opt/stack/nova/nova/utils.py", line 1193, in safe_truncate
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server b_value = encodeutils.safe_encode(value)[:length]
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server File "/usr/local/lib/python2.7/dist-packages/oslo_utils/encodeutils.py", line 85, in safe_encode
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server raise TypeError("%s can't be encoded" % type(text))
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server TypeError: <class 'neutronclient.common.exceptions.Forbidden'> can't be encoded
Oct 02 04:39:13 testzun nova-compute[24239]: ERROR oslo_messaging.rpc.server
Oct 02 04:39:13 testzun <email address hidden>[24253]: ERROR nova.api.openstack.extensions [None req-3e125907-0419-418a-a03c-154b99e97610 demo demo] Unexpected exception in API method: TypeError: <class 'neutronclient.common.exceptions.Forbidden'> can't be encoded
Reviewed: https:/ /review. openstack. org/508802 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=f1a0557da4f bd7baa9196cb5c0 ccdd7ebb16ecdf
Committed: https:/
Submitter: Zuul
Branch: master
commit f1a0557da4fbd7b aa9196cb5c0ccdd 7ebb16ecdf
Author: Hongbin Lu <email address hidden>
Date: Mon Oct 2 04:21:26 2017 +0000
Fix wrapping of neutron forbidden error
In neutronv2 api, the neutron forbidden error is not wrapped
correctly. The exception class expects the first parameter as
the error message but an exception object is passed.
Closes-Bug: #1720726 efe2122274b0277 5f013404e30
Change-Id: I6e88333427ec2b