← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1714072] [NEW] PUT /allocations/{consumer_id} fails with a 500 if "resources: {}"

 

Public bug reported:

I hit this while writing a functional recreate test for bug 1713786
where the destination node during an evacuate doesn't have it's
allocations created by the scheduler. When the source node comes up
after the evacuation, it tries to remove the allocations on the source
node, which is the only one because of bug 1713786, but that results in
sending a request like this:

2017-08-30 14:45:13,495 INFO [nova.scheduler.client.report] Sending
updated allocation [{'resource_provider': {'uuid':
'7ab9dab7-65c6-4961-9403-c8fc50dedb6b'}, 'resources': {}}] for instance
dc8a686c-ad92-48f3-8594-d00c6e671a1c after removing resources for
7ab9dab7-65c6-4961-9403-c8fc50dedb6b.

And you get this stacktrace in the Placement API:

2017-08-30 14:45:13,502 ERROR [nova.api.openstack.placement.handler] Uncaught exception
    Traceback (most recent call last):
      File "nova/api/openstack/placement/handler.py", line 217, in __call__
        return dispatch(environ, start_response, self._map)
      File "nova/api/openstack/placement/handler.py", line 144, in dispatch
        return handler(environ, start_response)
      File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/webob/dec.py", line 131, in __call__
        resp = self.call_func(req, *args, **self.kwargs)
      File "nova/api/openstack/placement/wsgi_wrapper.py", line 29, in call_func
        super(PlacementWsgify, self).call_func(req, *args, **kwargs)
      File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/webob/dec.py", line 196, in call_func
        return self.func(req, *args, **kwargs)
      File "nova/api/openstack/placement/microversion.py", line 268, in decorated_func
        return _find_method(f, version)(req, *args, **kwargs)
      File "nova/api/openstack/placement/util.py", line 138, in decorated_function
        return f(req)
      File "nova/api/openstack/placement/handlers/allocation.py", line 286, in set_allocations
        return _set_allocations(req, ALLOCATION_SCHEMA_V1_8)
      File "nova/api/openstack/placement/handlers/allocation.py", line 252, in _set_allocations
        allocations.create_all()
      File "nova/objects/resource_provider.py", line 1877, in create_all
        self._set_allocations(self._context, self.objects)
      File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/oslo_db/api.py", line 150, in wrapper
        ectxt.value = e.inner_exc
      File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
        self.force_reraise()
      File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
        six.reraise(self.type_, self.value, self.tb)
      File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/oslo_db/api.py", line 138, in wrapper
        return f(*args, **kwargs)
      File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py", line 979, in wrapper
        return fn(*args, **kwargs)
      File "nova/objects/resource_provider.py", line 1835, in _set_allocations
        consumer_id = allocs[0].consumer_id
    IndexError: list index out of range


The schema validation on PUT /allocations requires a minimum of one provider in the request, but it doesn't validate that there is at least one resource for that provider:

https://github.com/openstack/nova/blob/da4083d7bc0a0c1272df35ecb12c4c2fd2102e21/nova/api/openstack/placement/handlers/allocation.py#L52-L61

** Affects: nova
     Importance: Medium
         Status: Triaged

** Affects: nova/pike
     Importance: Undecided
         Status: New


** Tags: api placement

** Also affects: nova/pike
   Importance: Undecided
       Status: New

-- 
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/1714072

Title:
  PUT /allocations/{consumer_id} fails with a 500 if "resources: {}"

Status in OpenStack Compute (nova):
  Triaged
Status in OpenStack Compute (nova) pike series:
  New

Bug description:
  I hit this while writing a functional recreate test for bug 1713786
  where the destination node during an evacuate doesn't have it's
  allocations created by the scheduler. When the source node comes up
  after the evacuation, it tries to remove the allocations on the source
  node, which is the only one because of bug 1713786, but that results
  in sending a request like this:

  2017-08-30 14:45:13,495 INFO [nova.scheduler.client.report] Sending
  updated allocation [{'resource_provider': {'uuid':
  '7ab9dab7-65c6-4961-9403-c8fc50dedb6b'}, 'resources': {}}] for
  instance dc8a686c-ad92-48f3-8594-d00c6e671a1c after removing resources
  for 7ab9dab7-65c6-4961-9403-c8fc50dedb6b.

  And you get this stacktrace in the Placement API:

  2017-08-30 14:45:13,502 ERROR [nova.api.openstack.placement.handler] Uncaught exception
      Traceback (most recent call last):
        File "nova/api/openstack/placement/handler.py", line 217, in __call__
          return dispatch(environ, start_response, self._map)
        File "nova/api/openstack/placement/handler.py", line 144, in dispatch
          return handler(environ, start_response)
        File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/webob/dec.py", line 131, in __call__
          resp = self.call_func(req, *args, **self.kwargs)
        File "nova/api/openstack/placement/wsgi_wrapper.py", line 29, in call_func
          super(PlacementWsgify, self).call_func(req, *args, **kwargs)
        File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/webob/dec.py", line 196, in call_func
          return self.func(req, *args, **kwargs)
        File "nova/api/openstack/placement/microversion.py", line 268, in decorated_func
          return _find_method(f, version)(req, *args, **kwargs)
        File "nova/api/openstack/placement/util.py", line 138, in decorated_function
          return f(req)
        File "nova/api/openstack/placement/handlers/allocation.py", line 286, in set_allocations
          return _set_allocations(req, ALLOCATION_SCHEMA_V1_8)
        File "nova/api/openstack/placement/handlers/allocation.py", line 252, in _set_allocations
          allocations.create_all()
        File "nova/objects/resource_provider.py", line 1877, in create_all
          self._set_allocations(self._context, self.objects)
        File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/oslo_db/api.py", line 150, in wrapper
          ectxt.value = e.inner_exc
        File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/oslo_utils/excutils.py", line 220, in __exit__
          self.force_reraise()
        File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/oslo_utils/excutils.py", line 196, in force_reraise
          six.reraise(self.type_, self.value, self.tb)
        File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/oslo_db/api.py", line 138, in wrapper
          return f(*args, **kwargs)
        File "/home/user/git/nova/.tox/functional/local/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py", line 979, in wrapper
          return fn(*args, **kwargs)
        File "nova/objects/resource_provider.py", line 1835, in _set_allocations
          consumer_id = allocs[0].consumer_id
      IndexError: list index out of range

  
  The schema validation on PUT /allocations requires a minimum of one provider in the request, but it doesn't validate that there is at least one resource for that provider:

  https://github.com/openstack/nova/blob/da4083d7bc0a0c1272df35ecb12c4c2fd2102e21/nova/api/openstack/placement/handlers/allocation.py#L52-L61

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


Follow ups