Translate NoMoreFloatingIps exception in floating ip create API

Bug #1169811 reported by Christopher Yeoh
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Christopher Yeoh

Bug Description

In tempest test test_allocate_floating_ip_from_nonexistent_pool an attempt is made to allocate a floating ip from a non existant pool. Nova correctly returns a 404, but leaves a stacktrace in the log files

2013-04-17 11:25:54 DEBUG [routes.middleware] Matched POST /418618d2fea641f69e6966afafe33e0c/os-floating-ips
2013-04-17 11:25:54 DEBUG [routes.middleware] Route path: '/{project_id}/os-floating-ips', defaults: {'action': u'crea
te', 'controller': <nova.api.openstack.wsgi.Resource object at 0x31eaf10>}
2013-04-17 11:25:54 DEBUG [routes.middleware] Match dict: {'action': u'create', 'controller': <nova.api.openstack.wsgi
.Resource object at 0x31eaf10>, 'project_id': u'418618d2fea641f69e6966afafe33e0c'}
2013-04-17 11:25:54 DEBUG [nova.api.openstack.wsgi] Action: 'create', body: <?xml version="1.0" encoding="UTF-8"?>
<pool >non_exist_pool</pool>
2013-04-17 11:25:54 DEBUG [nova.api.openstack.wsgi] Calling method <bound method FloatingIPController.create of <nova.
api.openstack.compute.contrib.floating_ips.FloatingIPController object at 0x2f7bad0>>
2013-04-17 11:25:54 DEBUG [nova.quota] Created reservations ['a2d9fde5-fd43-42be-9c8d-abd4c15d311e']
2013-04-17 11:25:54 DEBUG [nova.quota] Rolled back reservations ['a2d9fde5-fd43-42be-9c8d-abd4c15d311e']
2013-04-17 11:25:54 ERROR [nova.api.openstack] Caught error: Zero floating ips available.
Traceback (most recent call last):
  File "/srv/compile/openstack/nova/nova/api/openstack/__init__.py", line 81, in __call__
    return req.get_response(self.application)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1296, in send
    application, catch_exc_info=False)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1260, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
    return resp(environ, start_response)
  File "/opt/stack/python-keystoneclient/keystoneclient/middleware/auth_token.py", line 451, in __call__
    return self.app(env, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
    return resp(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
    return resp(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
    return resp(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 130, in __call__
   resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 195, in call_func
    return self.func(req, *args, **kwargs)
  File "/srv/compile/openstack/nova/nova/api/openstack/wsgi.py", line 899, in __call__
    content_type, body, accept)
  File "/srv/compile/openstack/nova/nova/api/openstack/wsgi.py", line 951, in _process_stack
    action_result = self.dispatch(meth, request, action_args)
  File "/srv/compile/openstack/nova/nova/api/openstack/wsgi.py", line 1030, in dispatch
    return method(req=request, **action_args)
  File "/srv/compile/openstack/nova/nova/api/openstack/compute/contrib/floating_ips.py", line 161, in create
    address = self.network_api.allocate_floating_ip(context, pool)
  File "/srv/compile/openstack/nova/nova/network/api.py", line 90, in wrapped
    return func(self, context, *args, **kwargs)
  File "/srv/compile/openstack/nova/nova/network/api.py", line 212, in allocate_floating_ip
    context.project_id, False, pool)
  File "/srv/compile/openstack/nova/nova/utils.py", line 1349, in wrapper
    return func(*args, **kwargs)
  File "/srv/compile/openstack/nova/nova/network/floating_ips.py", line 240, in allocate_floating_ip
    QUOTAS.rollback(context, reservations)
  File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
    self.gen.next()
  File "/srv/compile/openstack/nova/nova/network/floating_ips.py", line 227, in allocate_floating_ip
    pool)
  File "/srv/compile/openstack/nova/nova/db/api.py", line 257, in floating_ip_allocate_address
    return IMPL.floating_ip_allocate_address(context, project_id, pool)
  File "/srv/compile/openstack/nova/nova/db/sqlalchemy/api.py", line 113, in wrapper
    return f(*args, **kwargs)
  File "/srv/compile/openstack/nova/nova/db/sqlalchemy/api.py", line 679, in floating_ip_allocate_address
    raise exception.NoMoreFloatingIps()
NoMoreFloatingIps: Zero floating ips available.
2013-04-17 11:25:54 INFO [nova.api.openstack] http://192.168.1.18:8774/v2/418618d2fea641f69e6966afafe33e0c/os-floating-ips returned with HTTP 404
2013-04-17 11:25:54 DEBUG [nova.api.openstack.wsgi] Returning 404 to user: NoMoreFloatingIps: Zero floating ips availa
g-ips returned with HTTP 404
2013-04-17 11:25:54 DEBUG [nova.api.openstack.wsgi] Returning 404 to user: NoMoreFloatingIps: Zero floating ips available.
2013-04-17 11:25:54 INFO [nova.osapi_compute.wsgi.server] 192.168.1.18 "POST /v2/418618d2fea641f69e6966afafe33e0c/os-floating-ips HTTP/1.1" status: 404 len: 351 time: 0.0572748

We should catch the exception and raise an HTTPNotFound instead so we don't leave a confusing stack trace when in an expected code path

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
assignee: nobody → Christopher Yeoh (cyeoh-0)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/27036
Committed: http://github.com/openstack/nova/commit/f9be01a42a513d7d579cc2424a439ae800ec6df6
Submitter: Jenkins
Branch: master

commit f9be01a42a513d7d579cc2424a439ae800ec6df6
Author: Chris Yeoh <email address hidden>
Date: Wed Apr 17 13:02:02 2013 +0930

    Translate NoMoreFloatingIps exception

    When the pool of floating ips is exhausted the NoMoreFloatingIps exception
    is raised but not handled properly in the floating ips extension resulting
    in the exception propagating further up and causing a stack trace to be logged.

    This change translates the exception explicitly into a HTTPNotFound, preserving the current
    REST API behaviour. It fixes a bug where the pool name was not correctly inserted into
    the message returned if allocation from a specific pool was requested.

    Fixes bug 1169811

    Part of blueprint no-stacktraces-in-logs

    Change-Id: I8f35d25d065bb1fa709cff6f59841ac8c86658bd

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → havana-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: havana-1 → 2013.2
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.