From 417ea13815521e6761e80191a2b133a4ea44c414 Mon Sep 17 00:00:00 2001 From: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> Date: Sat, 12 Oct 2024 23:12:52 +0900 Subject: [PATCH 1/3] fix snapshot restore and recovery endpoint Signed-off-by: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> --- spec/namespaces/snapshot.yaml | 5 +- spec/schemas/indices.recovery.yaml | 8 +++ tests/snapshot/snapshot/restore.yaml | 101 +++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 tests/snapshot/snapshot/restore.yaml diff --git a/spec/namespaces/snapshot.yaml b/spec/namespaces/snapshot.yaml index 58ad5f82e..7afd728eb 100644 --- a/spec/namespaces/snapshot.yaml +++ b/spec/namespaces/snapshot.yaml @@ -427,10 +427,11 @@ components: schema: type: object properties: + accepted: + description: Equals `true` if the restore was accepted. Present when the request had `wait_for_completion` set to `false` + type: boolean snapshot: $ref: '../schemas/snapshot.restore.yaml#/components/schemas/SnapshotRestore' - required: - - snapshot snapshot.status@200: content: application/json: diff --git a/spec/schemas/indices.recovery.yaml b/spec/schemas/indices.recovery.yaml index d2b781830..17019bfad 100644 --- a/spec/schemas/indices.recovery.yaml +++ b/spec/schemas/indices.recovery.yaml @@ -175,6 +175,14 @@ components: $ref: '_common.yaml#/components/schemas/Uuid' index: $ref: '_common.yaml#/components/schemas/IndexName' + isSearchableSnapshot: + type: boolean + remoteStoreIndexShallowCopy: + type: boolean + sourceRemoteStoreRepository: + type: ['null', string] + sourceRemoteTranslogRepository: + type: ['null', string] RecoveryStartStatus: type: object properties: diff --git a/tests/snapshot/snapshot/restore.yaml b/tests/snapshot/snapshot/restore.yaml new file mode 100644 index 000000000..6e229d255 --- /dev/null +++ b/tests/snapshot/snapshot/restore.yaml @@ -0,0 +1,101 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test _snapshot/{repository}/{snapshot}/_restore endpoints. +epilogues: + - path: /_snapshot/{repository}/{snapshot} + method: DELETE + status: [200, 404] + parameters: + repository: my-fs-repository + snapshot: my-test-snapshot + - path: /_snapshot/{repository} + method: DELETE + status: [200, 404] + parameters: + repository: my-fs-repository + - path: /restore-index-wait-true + method: DELETE + status: [200, 404] + - path: /restore-index-wait-false + method: DELETE + status: [200, 404] +prologues: + - path: /_snapshot/{repository} + method: PUT + parameters: + repository: my-fs-repository + request: + payload: + type: fs + settings: + location: /tmp/opensearch/repo + - path: /restore-index-wait-true + method: PUT + - path: /restore-index-wait-false + method: PUT + - path: /_snapshot/{repository}/{snapshot} + method: PUT + parameters: + repository: my-fs-repository + snapshot: my-test-snapshot + wait_for_completion: true + request: + payload: + indices: + - restore-index-wait-false + - restore-index-wait-true + ignore_unavailable: true + include_global_state: false + partial: true + - path: /restore-index-wait-true + method: DELETE + status: [200, 404] + - path: /restore-index-wait-false + method: DELETE + status: [200, 404] +chapters: + - synopsis: Restore snapshot with wait_for_completion true. + path: /_snapshot/{repository}/{snapshot}/_restore + method: POST + parameters: + repository: my-fs-repository + snapshot: my-test-snapshot + wait_for_completion: true + request: + payload: + indices: restore-index-wait-true + response: + status: 200 + payload: + snapshot: + snapshot: my-test-snapshot + - synopsis: Restore snapshot with wait_for_completion false. + path: /_snapshot/{repository}/{snapshot}/_restore + method: POST + parameters: + repository: my-fs-repository + snapshot: my-test-snapshot + wait_for_completion: false + request: + payload: + indices: restore-index-wait-false + response: + status: 200 + payload: + accepted: true + - synopsis: Wait finish async restore. + path: /{index}/_recovery + warnings: + multiple-paths-detected: false + method: GET + parameters: + index: restore-index-wait-false + response: + status: 200 + payload: + restore-index-wait-false: + shards: + - stage: DONE + type: SNAPSHOT + retry: + count: 3 \ No newline at end of file From f3e6158e1414edd91b6f17c3be0d65c33f7682bc Mon Sep 17 00:00:00 2001 From: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> Date: Sat, 12 Oct 2024 23:21:10 +0900 Subject: [PATCH 2/3] add changelog Signed-off-by: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13a7e05fb..2a5685faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -177,6 +177,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed mapping and analysis types ([#600](https://github.com/opensearch-project/opensearch-api-specification/pull/600)) - Fixed `RestStatus` responses in `DELETE /_plugins/_notifications/configs/{config_id}` ([#594](https://github.com/opensearch-project/opensearch-api-specification/pull/594)) - Fixed `GET /_snapshot_/{repository}/{snapshot}` ([#608](https://github.com/opensearch-project/opensearch-api-specification/pull/608)) +- Fixed `POST /_snapshot/{repository}/{snapshot}/_restore` when wait_for_completion is false and `GET /{index}/_recovery` ([#611](https://github.com/opensearch-project/opensearch-api-specification/pull/611)) ### Security From c483acb8d785720957a3e68732b08c224a32c1b9 Mon Sep 17 00:00:00 2001 From: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:39:37 +0900 Subject: [PATCH 3/3] Fixed index naming, description and changelog Signed-off-by: Tatsuya Kawakami <43780506+hogesako@users.noreply.github.com> --- CHANGELOG.md | 2 +- spec/namespaces/snapshot.yaml | 4 ++-- tests/snapshot/snapshot/restore.yaml | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a5685faa..eeeae2b11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -177,7 +177,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed mapping and analysis types ([#600](https://github.com/opensearch-project/opensearch-api-specification/pull/600)) - Fixed `RestStatus` responses in `DELETE /_plugins/_notifications/configs/{config_id}` ([#594](https://github.com/opensearch-project/opensearch-api-specification/pull/594)) - Fixed `GET /_snapshot_/{repository}/{snapshot}` ([#608](https://github.com/opensearch-project/opensearch-api-specification/pull/608)) -- Fixed `POST /_snapshot/{repository}/{snapshot}/_restore` when wait_for_completion is false and `GET /{index}/_recovery` ([#611](https://github.com/opensearch-project/opensearch-api-specification/pull/611)) +- Fixed `POST /_snapshot/{repository}/{snapshot}/_restore` when `wait_for_completion` is `false` and `GET /{index}/_recovery` ([#611](https://github.com/opensearch-project/opensearch-api-specification/pull/611)) ### Security diff --git a/spec/namespaces/snapshot.yaml b/spec/namespaces/snapshot.yaml index 7afd728eb..d81a5b173 100644 --- a/spec/namespaces/snapshot.yaml +++ b/spec/namespaces/snapshot.yaml @@ -383,7 +383,7 @@ components: type: object properties: accepted: - description: Equals `true` if the snapshot was accepted. Present when the request had `wait_for_completion` set to `false` + description: Returns `true` if the snapshot was accepted. Present when the request had `wait_for_completion` set to `false`. type: boolean snapshot: $ref: '../schemas/snapshot._common.yaml#/components/schemas/SnapshotInfo' @@ -428,7 +428,7 @@ components: type: object properties: accepted: - description: Equals `true` if the restore was accepted. Present when the request had `wait_for_completion` set to `false` + description: Returns `true` if the restore was accepted. Present when the request had `wait_for_completion` set to `false`. type: boolean snapshot: $ref: '../schemas/snapshot.restore.yaml#/components/schemas/SnapshotRestore' diff --git a/tests/snapshot/snapshot/restore.yaml b/tests/snapshot/snapshot/restore.yaml index 6e229d255..970a39f00 100644 --- a/tests/snapshot/snapshot/restore.yaml +++ b/tests/snapshot/snapshot/restore.yaml @@ -13,10 +13,10 @@ epilogues: status: [200, 404] parameters: repository: my-fs-repository - - path: /restore-index-wait-true + - path: /movies method: DELETE status: [200, 404] - - path: /restore-index-wait-false + - path: /books method: DELETE status: [200, 404] prologues: @@ -29,9 +29,9 @@ prologues: type: fs settings: location: /tmp/opensearch/repo - - path: /restore-index-wait-true + - path: /movies method: PUT - - path: /restore-index-wait-false + - path: /books method: PUT - path: /_snapshot/{repository}/{snapshot} method: PUT @@ -42,15 +42,15 @@ prologues: request: payload: indices: - - restore-index-wait-false - - restore-index-wait-true + - books + - movies ignore_unavailable: true include_global_state: false partial: true - - path: /restore-index-wait-true + - path: /movies method: DELETE status: [200, 404] - - path: /restore-index-wait-false + - path: /books method: DELETE status: [200, 404] chapters: @@ -63,7 +63,7 @@ chapters: wait_for_completion: true request: payload: - indices: restore-index-wait-true + indices: movies response: status: 200 payload: @@ -78,7 +78,7 @@ chapters: wait_for_completion: false request: payload: - indices: restore-index-wait-false + indices: books response: status: 200 payload: @@ -89,11 +89,11 @@ chapters: multiple-paths-detected: false method: GET parameters: - index: restore-index-wait-false + index: books response: status: 200 payload: - restore-index-wait-false: + books: shards: - stage: DONE type: SNAPSHOT