Skip to content

Commit

Permalink
Added schema for cluster routing awareness.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <dblock@amazon.com>
  • Loading branch information
dblock committed Aug 22, 2024
1 parent b28c1cf commit b6129d7
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 17 additions & 2 deletions spec/namespaces/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
23 changes: 23 additions & 0 deletions spec/schemas/cluster.weighted_routing.yaml
Original file line number Diff line number Diff line change
@@ -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

35 changes: 35 additions & 0 deletions tests/default/cluster/routing/awareness/weights.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b6129d7

Please sign in to comment.