← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1704574] Re: [placement] attempt to put allocation to resource provide that does not host class of resource causes 500

 

** Also affects: nova/ocata
   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/1704574

Title:
  [placement] attempt to put allocation to resource provide that does
  not host class of resource causes 500

Status in OpenStack Compute (nova):
  In Progress
Status in OpenStack Compute (nova) ocata series:
  New

Bug description:
  I made a typo while writing some gabbi tests and uncovered a 500 in
  the placement service. If you try to allocate to a resource provider
  that does not host that class of resource it can have a KeyError
  during capacity checking. given the following gabbi in microversion
  1.10:

  - name: create a resource provider
    POST: /resource_providers
    data:
        name: an rp
    status: 201                                                                  
    
  - name: get resource provider
    GET: $LOCATION                                                               
    status: 200
    
  - name: create a resource class                                                
    PUT: /resource_classes/CUSTOM_GOLD                                           
    status: 201                                                                  
        
  - name: add inventory to an rp
    PUT: /resource_providers/$HISTORY['get resource provider'].$RESPONSE['$.uuid']/inventories
    data:                                                                        
        resource_provider_generation: 0                                          
        inventories:
            VCPU:
                total: 24
            CUSTOM_GOLD:                                                         
                total: 5
    status: 200
        
  - name: allocate some of it                                                    
    PUT: /allocations/6d9f83db-6eb5-49f6-84b0-5d03c6aa9fc8                       
    data:                                                                        
        allocations:
            - resource_provider:
                  uuid: $HISTORY['get resource provider'].$RESPONSE['$.uuid']    
              resources:
                  DISK_GB: 5                                                     
                  CUSTOM_GOLD: 1                                                 
        project_id: 42a32c07-3eeb-4401-9373-68a8cdca6784                         
        user_id: 66cb2f29-c86d-47c3-8af5-69ae7b778c70
    status: 204

  when DISK_GB is checked for capacity, we get:

  2017-07-15 17:41:47,224 ERROR [nova.api.openstack.placement.handler] Uncaught exception
  Traceback (most recent call last):
    File "nova/api/openstack/placement/handler.py", line 215, 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/cdent/src/nova/.tox/cover/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/cdent/src/nova/.tox/cover/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 285, in set_allocations
      return _set_allocations(req, ALLOCATION_SCHEMA_V1_8)
    File "nova/api/openstack/placement/handlers/allocation.py", line 249, in _set_allocations
      allocations.create_all()
    File "nova/objects/resource_provider.py", line 1851, in create_all
      self._set_allocations(self._context, self.objects)
    File "/home/cdent/src/nova/.tox/cover/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 1811, in _set_allocations
      before_gens = _check_capacity_exceeded(conn, allocs)
    File "nova/objects/resource_provider.py", line 1615, in _check_capacity_exceeded
      usage = usage_map[key]
  KeyError: ('14930a42-78df-4038-aafa-c959e18111e5', 2)

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


References