Merge "Fix 409 handling in report client when deleting inventory"

This commit is contained in:
Jenkins 2017-08-04 16:52:08 +00:00 committed by Gerrit Code Review
commit 2e75b91026
3 changed files with 7 additions and 6 deletions

View File

@ -409,11 +409,10 @@ def delete_inventories(req):
'%(rp_uuid)s because the inventory was updated by '
'another process. Please retry your request.')
% {'rp_uuid': resource_provider.uuid})
except exception.InventoryInUse:
raise webob.exc.HTTPConflict(
_('Unable to delete inventory for resource provider '
'%(rp_uuid)s because the inventory is in use.')
% {'rp_uuid': resource_provider.uuid})
except exception.InventoryInUse as ex:
# NOTE(mriedem): This message cannot change without impacting the
# nova.scheduler.client.report._RE_INV_IN_USE regex.
raise webob.exc.HTTPConflict(explanation=ex.format_message())
response = req.response
response.status = 204

View File

@ -2101,6 +2101,8 @@ class InvalidInventory(Invalid):
class InventoryInUse(InvalidInventory):
# NOTE(mriedem): This message cannot change without impacting the
# nova.scheduler.client.report._RE_INV_IN_USE regex.
msg_fmt = _("Inventory for '%(resource_classes)s' on "
"resource provider '%(resource_provider)s' in use.")

View File

@ -40,7 +40,7 @@ tests:
response_headers:
content-type: /application/json/
response_strings:
- Unable to delete inventory for resource provider $ENVIRON['RP_UUID'] because the inventory is in use.
- "Inventory for 'VCPU, DISK_GB' on resource provider '$ENVIRON['RP_UUID']' in use"
- name: get total usages by project
GET: /usages?project_id=$ENVIRON['PROJECT_ID']