Neutron driver handles incorrectly 404 errors

Bug #1747167 reported by Cedric Brandily
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Cedric Brandily

Bug Description

Neutronclient transforms errors using exception_handler_v20[1].
In particular, it transforms 404 responses into:
 1) [2] neutronclient.common.exceptions.<type>Client if response body contains a type attribute (with value <type>, type examples: NetworkNotFound, PortNotFound) and <type>Client exists
 2) [3] neutronclient.common.NotFound otherwise

Nova neutron driver[4] supports mostly 1) but not 2).
But Neutron in case of 404 returns the following body:

  {"message": "The resource could not be found.<br /><br />\n\n\n", "code": "404 Not Found", "title": "Not Found"}

and we end in 2) and Nova Neutron driver doesn't catch the error correctly and raises a 500

You can reproduce it indirectly using:
 openstack server add fixed ip <vm> <network-name>

which queries:
 nova-base-url/os-networks/<network-name>

assuming it would return the network or a 404 but it returns 500.

This trouble can be solved by catching NotFound instead of NetworkNotFoundClient/PortNotFoundClient as there are subclasses of NotFound.

[1] https://github.com/openstack/python-neutronclient/blob/6a2112e1824980af1bc9216441fa58a7dfd00988/neutronclient/v2_0/client.py#L47-L93
[2] https://github.com/openstack/python-neutronclient/blob/6a2112e1824980af1bc9216441fa58a7dfd00988/neutronclient/v2_0/client.py#L71
[3] https://github.com/openstack/python-neutronclient/blob/6a2112e1824980af1bc9216441fa58a7dfd00988/neutronclient/v2_0/client.py#L85
[4] nova.network.neutronv2.api

Changed in nova:
assignee: nobody → Cedric Brandily (cbrandily)
description: updated
Changed in nova:
status: New → Confirmed
importance: Undecided → Low
tags: added: low-hanging-fruit neutron
Revision history for this message
Stepan G. Fedorov (stfedorov) wrote :

Also got this issue in production.

openstack server add fixed ip <vm> <network-name> always results in 500.

We use Newton release, and need a bugfix ASAP.

Revision history for this message
Alexey Stupnikov (astupnikov) wrote :

This problem is not reproducible in stable/train:

$ openstack server add fixed ip 4a313732-138d-44aa-ba16-eac3d5ecf678 0b9d07e9-524d-4ab1-8206-5446af2d7746
none found (HTTP 404)

and in stable/queens:
$ openstack server add fixed ip d4d217ee-f1e3-497d-9835-8ae0e917c6a0 e2bc07ef-c7ba-4ca7-9c32-4803f852e21b
keys: ['label']
Not found (HTTP none found)

This bug seem to be a duplicate of bug #1649852

Revision history for this message
Alexey Stupnikov (astupnikov) wrote :

OK, maybe not a duplicate, but changed workflow for recent releases:

2020-05-23 17:18:34.101 17 DEBUG nova.api.openstack.wsgi [req-ea0481e8-4135-40fa-ba7d-008d95a205e4 e06bc0993eff4364a78724b2b121b58e 78e4238746cc4006b8288fdfca08725a - default default] Calli
ng method '<function version_select at 0x7f2253d9e050>' _process_stack /usr/lib/python2.7/site-packages/nova/api/openstack/wsgi.py:607
2020-05-23 17:18:34.136 17 DEBUG neutronclient.v2_0.client [req-ea0481e8-4135-40fa-ba7d-008d95a205e4 e06bc0993eff4364a78724b2b121b58e 78e4238746cc4006b8288fdfca08725a - default default] Err
or message: {"NeutronError": {"message": "Network e2bc07ef-c7ba-4ca7-9c32-4803f852e21b could not be found.", "type": "NetworkNotFound", "detail": ""}} _handle_fault_response /usr/lib/python
2.7/site-packages/neutronclient/v2_0/client.py:259
2020-05-23 17:18:34.137 17 INFO nova.api.openstack.wsgi [req-ea0481e8-4135-40fa-ba7d-008d95a205e4 e06bc0993eff4364a78724b2b121b58e 78e4238746cc4006b8288fdfca08725a - default default] HTTP e
xception thrown: Network not found
2020-05-23 17:18:34.138 17 DEBUG nova.api.openstack.wsgi [req-ea0481e8-4135-40fa-ba7d-008d95a205e4 e06bc0993eff4364a78724b2b121b58e 78e4238746cc4006b8288fdfca08725a - default default] Retur
ning 404 to user: Network not found __call__ /usr/lib/python2.7/site-packages/nova/api/openstack/wsgi.py:1064
2020-05-23 17:18:34.139 17 INFO nova.api.openstack.requestlog [req-ea0481e8-4135-40fa-ba7d-008d95a205e4 e06bc0993eff4364a78724b2b121b58e 78e4238746cc4006b8288fdfca08725a - default default] 172.17.1.15 "GET /v2.1/os-networks/e2bc07ef-c7ba-4ca7-9c32-4803f852e21b" status: 404 len: 63 microversion: 2.1 time: 0.041985

Revision history for this message
Alexey Stupnikov (astupnikov) wrote :

Changing bug's status to fix released as recent releases are no longer affected

Changed in nova:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.