From 7d4d49f41c83ae6af52dd52f71f2fd553683afcc Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 11 Jul 2022 13:00:07 +0100 Subject: [PATCH] Fix typo in schema We should have been specifying a minimum number of properties for the 'mappings' field when creating allocations [1]. We were not, thanks to a typo. Correct this typo. [1] https://docs.openstack.org/api-ref/placement/#allocations Change-Id: I79bd5bf36a57983c38abc9235a8420931f373ca4 Signed-off-by: Stephen Finucane --- placement/schemas/allocation.py | 2 +- .../functional/gabbits/allocations-mappings.yaml | 15 +++++++++++++-- ...tion-empty-mapping-field-f5f97de6df891362.yaml | 9 +++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/create-allocation-empty-mapping-field-f5f97de6df891362.yaml diff --git a/placement/schemas/allocation.py b/placement/schemas/allocation.py index bdf93795f..b4daac684 100644 --- a/placement/schemas/allocation.py +++ b/placement/schemas/allocation.py @@ -172,7 +172,7 @@ POST_ALLOCATIONS_V1_28["patternProperties"] = { # request group suffixes with lists of resource provider uuids. mappings_schema = { "type": "object", - "minProperites": 1, + "minProperties": 1, "patternProperties": { common.GROUP_PAT_1_33: { "type": "array", diff --git a/placement/tests/functional/gabbits/allocations-mappings.yaml b/placement/tests/functional/gabbits/allocations-mappings.yaml index cd112a05f..6583c0109 100644 --- a/placement/tests/functional/gabbits/allocations-mappings.yaml +++ b/placement/tests/functional/gabbits/allocations-mappings.yaml @@ -70,8 +70,19 @@ tests: project_id: b2e599e0-ded8-47fd-b8ab-ceb7fca578bd status: 400 response_json_paths: - # u? accounts for difference in Python 2.7 v. 3.x response - $.errors[0].detail: "/JSON does not validate: u?'beta' is not of type 'array'/" + $.errors[0].detail: "/JSON does not validate: 'beta' is not of type 'array'/" + +- name: put allocation mapping empty + PUT: /allocations/5f9588de-079d-462a-a459-408524ab9b60 + data: + allocations: $HISTORY['mappings request'].$RESPONSE['$.allocation_requests[0].allocations'] + mappings: {} + consumer_generation: null + user_id: 8c974f9a-f266-42f7-8613-a8017cbfb87F + project_id: b2e599e0-ded8-47fd-b8ab-ceb7fca578bd + status: 400 + response_json_paths: + $.errors[0].detail: "/JSON does not validate: {} does not have enough properties/" - name: post allocation with results POST: /allocations diff --git a/releasenotes/notes/create-allocation-empty-mapping-field-f5f97de6df891362.yaml b/releasenotes/notes/create-allocation-empty-mapping-field-f5f97de6df891362.yaml new file mode 100644 index 000000000..17fee7ed4 --- /dev/null +++ b/releasenotes/notes/create-allocation-empty-mapping-field-f5f97de6df891362.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + Since microversion 1.34, it has been possible to provide a ``mappings`` + field when creating new allocations via the ``POST /allocations`` or ``PUT + /allocations/{allocation_id}`` APIs. This field should be a a dictionary + associating request group suffixes with a list of UUIDs identifying the + resource providers that satisfied each group. Due to a typo, this was + allowing an empty object (``{}``). This is now corrected.