From b6129d7a05a7c54e62b198508bc6bd44037ed671 Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 22 Aug 2024 13:42:18 -0400 Subject: [PATCH] Added schema for cluster routing awareness. Signed-off-by: dblock --- CHANGELOG.md | 1 + spec/namespaces/cluster.yaml | 19 ++++++++-- spec/schemas/cluster.weighted_routing.yaml | 23 ++++++++++++ .../cluster/routing/awareness/weights.yaml | 35 +++++++++++++++++++ 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 spec/schemas/cluster.weighted_routing.yaml create mode 100644 tests/default/cluster/routing/awareness/weights.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index c5a91329c..f3221018b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `cancelled_task_percentage` and `current_cancellation_eligible_tasks_count` to `ShardSearchBackpressureTaskCancellationStats` ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483)) - Added detailed test coverage report ([#513](https://github.com/opensearch-project/opensearch-api-specification/pull/513)) - Added 404 responses to `/_alias/{name}` and `/{index}/_alias/{name}` ([#519](https://github.com/opensearch-project/opensearch-api-specification/pull/519)) +- Added request and response schemas for `/_cluster/routing/awareness/{attribute}/weights` ([#524](https://github.com/opensearch-project/opensearch-api-specification/pull/524)) ### Changed diff --git a/spec/namespaces/cluster.yaml b/spec/namespaces/cluster.yaml index c503c375b..562b115bf 100644 --- a/spec/namespaces/cluster.yaml +++ b/spec/namespaces/cluster.yaml @@ -195,6 +195,8 @@ paths: url: https://opensearch.org/docs/latest/api-reference/cluster-api/cluster-awareness/#example-weighted-round-robin-search parameters: - $ref: '#/components/parameters/cluster.put_weighted_routing::path.attribute' + requestBody: + $ref: '#/components/requestBodies/cluster.put_weighted_routing' responses: '200': $ref: '#/components/responses/cluster.put_weighted_routing@200' @@ -465,6 +467,11 @@ paths: $ref: '#/components/responses/cluster.remote_info@200' components: requestBodies: + cluster.put_weighted_routing: + content: + application/json: + schema: + $ref: '../schemas/cluster.weighted_routing.yaml#/components/schemas/Weights' cluster.allocation_explain: content: application/json: @@ -647,7 +654,11 @@ components: required: - persistent - transient - cluster.get_weighted_routing@200: {} + cluster.get_weighted_routing@200: + content: + application/json: + schema: + $ref: '../schemas/cluster.weighted_routing.yaml#/components/schemas/WeightsResponse' cluster.health@200: content: application/json: @@ -692,7 +703,11 @@ components: - acknowledged - persistent - transient - cluster.put_weighted_routing@200: {} + cluster.put_weighted_routing@200: + content: + application/json: + schema: + type: object cluster.remote_info@200: content: application/json: diff --git a/spec/schemas/cluster.weighted_routing.yaml b/spec/schemas/cluster.weighted_routing.yaml new file mode 100644 index 000000000..c4579ba8e --- /dev/null +++ b/spec/schemas/cluster.weighted_routing.yaml @@ -0,0 +1,23 @@ +openapi: 3.1.0 +info: + title: Schemas of Weighted Routing Category + description: Schemas of weighted routing category. + version: 1.0.0 +paths: {} +components: + schemas: + Weights: + type: object + properties: + _version: + $ref: '_common.yaml#/components/schemas/VersionNumber' + weights: + type: object + WeightsResponse: + allOf: + - $ref: '#/components/schemas/Weights' + - type: object + properties: + discovered_cluster_manager: + type: boolean + diff --git a/tests/default/cluster/routing/awareness/weights.yaml b/tests/default/cluster/routing/awareness/weights.yaml new file mode 100644 index 000000000..9d211e0f2 --- /dev/null +++ b/tests/default/cluster/routing/awareness/weights.yaml @@ -0,0 +1,35 @@ +$schema: ../../../../../json_schemas/test_story.schema.yaml + +description: Test cluster routing settings. +version: '>= 2.16' +prologues: + - path: /_cluster/settings + method: PUT + request: + payload: + transient: + cluster.routing.allocation.awareness.attributes: zone + cluster.routing.allocation.awareness.force.zone.values: + - zone-a + - zone-b +chapters: + - synopsis: Update zone routing weights. + path: /_cluster/routing/awareness/{attribute}/weights + method: PUT + parameters: + attribute: zone + request: + payload: + weights: + zone-a: '1' + zone-b: '0' + _version: 0 + response: + status: 200 + - synopsis: Get zone routing weights. + path: /_cluster/routing/awareness/{attribute}/weights + method: GET + parameters: + attribute: zone + response: + status: 200