remove_router_interface need to improve its validate to avoid 500 DBError

Bug #1416308 reported by watanabe.isao
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Undecided
watanabe.isao

Bug Description

500 DBError should not be returned in a user operation.

[User operation]
========================
curl -i -X PUT -H "X-Auth-Token: $TOKEN" -H "Content-Type: application/json" http://192.168.122.201:9696/v2.0/routers/edff6799-7f1b-4d9e-bc8e-115cd22afd82/remove_router_interface -d '{"id":"edff6799-7f1b-4d9e-remove_router_interface"}'
HTTP/1.1 500 Internal Server Error
Content-Type: application/json; charset=UTF-8
Content-Length: 150
X-Openstack-Request-Id: req-31c11f44-73c4-47bf-bbc3-a3b0eb41148d
Date: Fri, 30 Jan 2015 06:30:26 GMT

{"NeutronError": {"message": "Request Failed: internal server error while processing your request.", "type": "HTTPInternalServerError", "detail": ""}}
========================

When subnet_id or port_id is not defined in the body of the above RESR API request, 400 Error should be returned.
However, the varidate for this is not enough and cause a 500 DB Error.

[TraceLog]
========================
2015-01-28 21:37:16.956 2589 ERROR neutron.api.v2.resource [req-c65b69cd-9a1b-4083-b85f-ea98030f5022 None] add_router_interface failed
2015-01-28 21:37:16.956 2589 TRACE neutron.api.v2.resource Traceback (most recent call last):
2015-01-28 21:37:16.956 2589 TRACE neutron.api.v2.resource File "/usr/lib/python2.6/site-packages/neutron/api/v2/resource.py", line 87, in resource
2015-01-28 21:37:16.956 2589 TRACE neutron.api.v2.resource result = method(request=request, **args)
2015-01-28 21:37:16.956 2589 TRACE neutron.api.v2.resource File "/usr/lib/python2.6/site-packages/neutron/api/v2/base.py", line 194, in _handle_action
2015-01-28 21:37:16.956 2589 TRACE neutron.api.v2.resource return getattr(self._plugin, name)(*arg_list, **kwargs)
2015-01-28 21:37:16.956 2589 TRACE neutron.api.v2.resource File "/usr/lib/python2.6/site-packages/neutron/db/l3_db.py", line 367, in add_router_interface
2015-01-28 21:37:16.956 2589 TRACE neutron.api.v2.resource 'tenant_id': subnet['tenant_id'],
2015-01-28 21:37:16.956 2589 TRACE neutron.api.v2.resource UnboundLocalError: local variable 'subnet' referenced before assignment
2015-01-28 21:37:16.956 2589 TRACE neutron.api.v2.resource
========================

[About fix]
A varidate like in add_router_interface should be good enough.
See add_router_interface is returning 400 correctly.
========================
curl -i -X PUT -H "X-Auth-Token: $TOKEN" -H "Content-Type: application/json" http://192.168.122.201:9696/v2.0/routers/139d6962-0919-444a-8ee4-8e47e35f054b/add_router_interface -d '{"router":{"name":"test_router"}}'
HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=UTF-8
Content-Length: 134
X-Openstack-Request-Id: req-bca4b0ca-9e3a-4171-b783-ccc9a8c1cb80
Date: Thu, 29 Jan 2015 02:20:39 GMT

{"NeutronError": {"message": "Bad router request: Either subnet_id or port_id must be specified", "type": "BadRequest", "detail": ""}}
========================

Changed in neutron:
assignee: nobody → watanabe.isao (watanabe.isao)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/151973

Changed in neutron:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/151973
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=405baef29ffae96bcf5410d5d93217f219a1bfda
Submitter: Jenkins
Branch: master

commit 405baef29ffae96bcf5410d5d93217f219a1bfda
Author: watanabe.isao <email address hidden>
Date: Fri Jan 30 17:56:24 2015 +0900

    Improve validate of remove_router_interface

    Improve validate of remove_router_interface as described in
    API referrence [1].

    [1]http://developer.openstack.org/api-ref-networking-v2.html
       PUT: /v2.0/routers/{router_id}/add_router_interface
       PUT: /v2.0/routers/{router_id}/remove_router_interface

    Also, add missing unit tests to cover a [add; delete] time
    [none; subnet id only; port id only; both ids] matrices.

    Change-Id: Ie4ddf61c4a4930a58d0817119566d2285a394065
    Closes-Bug: #1416308

Changed in neutron:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in neutron:
milestone: none → kilo-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: kilo-rc1 → 2015.1.0
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.