Reviewed: https://review.openstack.org/279839 Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=d90115c3e806f896dc90e226af7b06b21ba92abc Submitter: Jenkins Branch: master
commit d90115c3e806f896dc90e226af7b06b21ba92abc Author: Matt Riedemann <[email protected]> Date: Fri Feb 12 18:34:59 2016 -0800 neutron: handle attach interface case with no networks It's possible to boot an instance without a network and it's also possible to try and attach an interface without specifying a port, network or fixed IP. If no network is specified on the attach request and there are no networks available to the instance's project (shared or not), then the allocate_port_for_instance method fails with an IndexError. The code is currently checking for a case of ambiguous networks when a specific network ID is not requested, but is not checking for the case that no network ID is specified and no networks are available. This change adds that check. A new type of exception is raised from the network API and handled in the REST API so we return a 400 to the user rather than a 500. Note that we don't return an empty network_info to the compute manager because that results in InterfaceAttachFailed raised to the REST API which is interpreted as a 500. Closes-Bug: #1545117 Change-Id: Iad762ebef08c259339ea5582e65266620fbab0ac ** Changed in: nova Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/1545117 Title: neutron: 500 error when trying to attach no network to an instance with no network Status in OpenStack Compute (nova): Fix Released Bug description: It's possible to create a VM with nova using neutron as the backend and have no network information. If the tenant doesn't have any available network in neutron and doesn't request any network, the neutron backend will simply log a message and continue. If you then later attempt to use the os-attach-interface API and don't provider a network, and the tenant still doesn't have any networks available in neutron, then the request fails in the neutronv2 API code with an IndexError because it's assuming there is at least one available network: http://paste.openstack.org/show/486856/ 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions Traceback (most recent call last): 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 143, in _dispatch_and_reply 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions executor_callback)) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 189, in _dispatch 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions executor_callback) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 130, in _do_dispatch 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions result = func(ctxt, **new_args) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/exception.py", line 110, in wrapped 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions payload) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 204, in __exit__ 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions six.reraise(self.type_, self.value, self.tb) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/exception.py", line 89, in wrapped 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions return f(self, context, *args, **kw) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/compute/manager.py", line 385, in decorated_function 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions kwargs['instance'], e, sys.exc_info()) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 204, in __exit__ 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions six.reraise(self.type_, self.value, self.tb) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/compute/manager.py", line 373, in decorated_function 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions return function(self, context, *args, **kwargs) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/compute/manager.py", line 4933, in attach_interface 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions context, instance, port_id, network_id, requested_ip) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/network/neutronv2/api.py", line 775, in allocate_port_for_instance 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions requested_networks=requested_networks) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions File "/opt/stack/nova/nova/network/neutronv2/api.py", line 579, in allocate_for_instance 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions objects.NetworkRequest(network_id=nets[0]['id'])) 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions 2016-02-12 09:34:32.188 TRACE nova.api.openstack.extensions IndexError: list index out of range We should at least handle that case and report a 400 to the user. To manage notifications about this bug go to: https://bugs.launchpad.net/nova/+bug/1545117/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

