← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1416308] [NEW] remove_router_interface need to improve its validate to avoid 500 DBError

 

Public bug reported:

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": ""}}
========================

** Affects: neutron
     Importance: Undecided
     Assignee: watanabe.isao (watanabe.isao)
         Status: New

** Changed in: neutron
     Assignee: (unassigned) => watanabe.isao (watanabe.isao)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1416308

Title:
  remove_router_interface need to improve its validate to avoid 500
  DBError

Status in OpenStack Neutron (virtual network service):
  New

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": ""}}
  ========================

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1416308/+subscriptions


Follow ups

References