From ad2c7a3c80edc78945b295c2dafe5681004a66fd Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Sat, 9 Sep 2017 02:47:30 +0100 Subject: [PATCH] [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 --- nova/api/openstack/placement/handlers/allocation.py | 6 +++--- .../api/openstack/placement/gabbits/allocations.yaml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/nova/api/openstack/placement/handlers/allocation.py b/nova/api/openstack/placement/handlers/allocation.py index 40ab62bd525d..7e3913e45082 100644 --- a/nova/api/openstack/placement/handlers/allocation.py +++ b/nova/api/openstack/placement/handlers/allocation.py @@ -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}) diff --git a/nova/tests/functional/api/openstack/placement/gabbits/allocations.yaml b/nova/tests/functional/api/openstack/placement/gabbits/allocations.yaml index b07ee9342b20..bf9b64833202 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/allocations.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/allocations.yaml @@ -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