diff --git a/nova/api/openstack/placement/handlers/aggregate.py b/nova/api/openstack/placement/handlers/aggregate.py index ed068b45ea89..a26839c3739d 100644 --- a/nova/api/openstack/placement/handlers/aggregate.py +++ b/nova/api/openstack/placement/handlers/aggregate.py @@ -122,7 +122,8 @@ def set_aggregates(req): if resource_provider.generation != rp_gen: raise webob.exc.HTTPConflict( _("Resource provider's generation already changed. Please " - "update the generation and try again.")) + "update the generation and try again."), + comment=errors.CONCURRENT_UPDATE) aggregate_uuids = data['aggregates'] else: aggregate_uuids = data diff --git a/nova/api/openstack/placement/handlers/inventory.py b/nova/api/openstack/placement/handlers/inventory.py index 492d15697f8c..46135761568f 100644 --- a/nova/api/openstack/placement/handlers/inventory.py +++ b/nova/api/openstack/placement/handlers/inventory.py @@ -331,7 +331,8 @@ def set_inventories(req): data = _extract_inventories(req.body, schema.PUT_INVENTORY_SCHEMA) if data['resource_provider_generation'] != resource_provider.generation: raise webob.exc.HTTPConflict( - _('resource provider generation conflict')) + _('resource provider generation conflict'), + comment=errors.CONCURRENT_UPDATE) inv_list = [] for res_class, inventory_data in data['inventories'].items(): @@ -436,7 +437,8 @@ def update_inventory(req): data = _extract_inventory(req.body, schema.BASE_INVENTORY_SCHEMA) if data['resource_provider_generation'] != resource_provider.generation: raise webob.exc.HTTPConflict( - _('resource provider generation conflict')) + _('resource provider generation conflict'), + comment=errors.CONCURRENT_UPDATE) inventory = _make_inventory_object(resource_provider, resource_class, diff --git a/nova/api/openstack/placement/handlers/trait.py b/nova/api/openstack/placement/handlers/trait.py index c5388f48eacc..b76907f1ad9f 100644 --- a/nova/api/openstack/placement/handlers/trait.py +++ b/nova/api/openstack/placement/handlers/trait.py @@ -226,7 +226,8 @@ def update_traits_for_resource_provider(req): raise webob.exc.HTTPConflict( _("Resource provider's generation already changed. Please update " "the generation and try again."), - json_formatter=util.json_error_formatter) + json_formatter=util.json_error_formatter, + comment=errors.CONCURRENT_UPDATE) trait_objs = rp_obj.TraitList.get_all( context, filters={'name_in': traits}) diff --git a/nova/api/openstack/placement/util.py b/nova/api/openstack/placement/util.py index 4192673e2d36..be4607074808 100644 --- a/nova/api/openstack/placement/util.py +++ b/nova/api/openstack/placement/util.py @@ -639,7 +639,8 @@ def ensure_consumer(ctx, consumer_uuid, project_id, user_id, { 'expected_gen': consumer.generation, 'got_gen': consumer_generation, - }) + }, + comment=errors.CONCURRENT_UPDATE) # NOTE(jaypipes): The user may have specified a different project and # user external ID than the one that we had for the consumer. If this # is the case, go ahead and modify the consumer record with the @@ -681,7 +682,8 @@ def ensure_consumer(ctx, consumer_uuid, project_id, user_id, if consumer_generation is not None: raise webob.exc.HTTPConflict( _('consumer generation conflict - ' - 'expected null but got %s') % consumer_generation) + 'expected null but got %s') % consumer_generation, + comment=errors.CONCURRENT_UPDATE) # No such consumer. This is common for new allocations. Create the # consumer record try: diff --git a/nova/tests/functional/api/openstack/placement/gabbits/aggregate.yaml b/nova/tests/functional/api/openstack/placement/gabbits/aggregate.yaml index 0d87a15d2459..fb75f9e7ae0e 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/aggregate.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/aggregate.yaml @@ -116,6 +116,8 @@ tests: resource_provider_generation: 0 aggregates: [] status: 409 + response_json_paths: + $.errors[0].code: placement.concurrent_update - name: clear those aggregates PUT: $LAST_URL diff --git a/nova/tests/functional/api/openstack/placement/gabbits/allocations-1.28.yaml b/nova/tests/functional/api/openstack/placement/gabbits/allocations-1.28.yaml index df8fadd66b72..77358836a560 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/allocations-1.28.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/allocations-1.28.yaml @@ -64,6 +64,8 @@ tests: response_strings: - consumer generation conflict - expected null but got 5 + response_json_paths: + $.errors[0].code: placement.concurrent_update - name: new version gen is None no existing PUT: /allocations/22222222-2222-2222-2222-222222222222 @@ -147,6 +149,8 @@ tests: status: 409 response_strings: - consumer generation conflict + response_json_paths: + $.errors[0].code: placement.concurrent_update - name: old version no gen existing PUT: /allocations/44444444-4444-4444-4444-444444444444 diff --git a/nova/tests/functional/api/openstack/placement/gabbits/inventory.yaml b/nova/tests/functional/api/openstack/placement/gabbits/inventory.yaml index 732f8a32ca79..6edff1f5dfcc 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/inventory.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/inventory.yaml @@ -220,6 +220,7 @@ tests: PUT: $LAST_URL request_headers: content-type: application/json + openstack-api-version: placement 1.23 data: resource_provider_generation: 5 total: 2048 @@ -228,6 +229,7 @@ tests: - resource provider generation conflict response_json_paths: $.errors[0].title: Conflict + $.errors[0].code: placement.concurrent_update - name: modify inventory no such resource class in inventory PUT: /resource_providers/$ENVIRON['RP_UUID']/inventories/MEMORY_MB @@ -467,6 +469,7 @@ tests: PUT: /resource_providers/$ENVIRON['RP_UUID']/inventories request_headers: content-type: application/json + openstack-api-version: placement 1.23 data: resource_provider_generation: 99 inventories: @@ -477,6 +480,7 @@ tests: - resource provider generation conflict response_json_paths: $.errors[0].title: Conflict + $.errors[0].code: placement.concurrent_update - name: put all inventory unknown resource class PUT: /resource_providers/$ENVIRON['RP_UUID']/inventories diff --git a/nova/tests/functional/api/openstack/placement/gabbits/traits.yaml b/nova/tests/functional/api/openstack/placement/gabbits/traits.yaml index 6312a243dcd7..a5010d2cb4d4 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/traits.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/traits.yaml @@ -325,6 +325,7 @@ tests: PUT: /resource_providers/$ENVIRON['RP_UUID']/traits request_headers: content-type: application/json + openstack-api-version: placement 1.23 status: 409 data: traits: @@ -332,6 +333,8 @@ tests: resource_provider_generation: 5 response_strings: - Resource provider's generation already changed. Please update the generation and try again. + response_json_paths: + $.errors[0].code: placement.concurrent_update - name: set non existed traits for resource provider PUT: /resource_providers/$ENVIRON['RP_UUID']/traits