[placement] correct error on bad resource class in allocation

A 400 is returned when making an allocation with a resource class that
does not exist, however the error message refers to whatever the most
recent resource provider uuid was rather than the one that was given
the bad resource class. Since the exception happens outside the loop
that creates the allocations we don't have the association to resource
provider uuid, but we do know which consumer uuid, so report that
instead.

Change-Id: I81dc6b566c6cca0b7d2ac267c3e632c8ae8cfb47
Closes-Bug: #1714402
This commit is contained in:
Chris Dent 2017-09-09 02:47:30 +01:00
parent 1aa1462b98
commit ad2c7a3c80
2 changed files with 4 additions and 3 deletions

View File

@ -257,9 +257,9 @@ def _set_allocations(req, schema):
# capacity limits have been exceeded.
except exception.NotFound as exc:
raise webob.exc.HTTPBadRequest(
_("Unable to allocate inventory for resource provider "
"%(rp_uuid)s: %(error)s") %
{'rp_uuid': resource_provider_uuid, 'error': exc})
_("Unable to allocate inventory for consumer "
"%(consumer_uuid)s: %(error)s") %
{'consumer_uuid': consumer_uuid, 'error': exc})
except exception.InvalidInventory as exc:
raise webob.exc.HTTPConflict(
_('Unable to allocate inventory: %(error)s') % {'error': exc})

View File

@ -192,6 +192,7 @@ tests:
COWS: 12
status: 400
response_strings:
- Unable to allocate inventory for consumer
- No such resource class COWS
response_json_paths:
$.errors[0].title: Bad Request