Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Exclude Patterns for Snapshot- and Repository Names in Get Snapshots API #77308

Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
654eeb1
Implement Exclude Patterns for Snapshot- and Repository Names in Get …
original-brownbear Sep 6, 2021
c3b989c
Merge remote-tracking branch 'elastic/master' into support-negative-s…
original-brownbear Sep 7, 2021
b0bc904
Merge remote-tracking branch 'elastic/master' into support-negative-s…
original-brownbear Sep 7, 2021
c0af03c
Merge remote-tracking branch 'elastic/master' into support-negative-s…
original-brownbear Sep 7, 2021
38e60c2
Merge remote-tracking branch 'elastic/master' into support-negative-s…
original-brownbear Sep 8, 2021
564eef8
Merge remote-tracking branch 'elastic/master' into support-negative-s…
original-brownbear Sep 8, 2021
6e4f0d9
make logic for resolving things nicer
original-brownbear Sep 8, 2021
081633a
align pattern usage
original-brownbear Sep 8, 2021
74e76f6
test with dash
original-brownbear Sep 8, 2021
de70f55
CR comments
original-brownbear Sep 8, 2021
61b5731
Merge branch 'master' into support-negative-snapshot-patterns
elasticmachine Sep 8, 2021
7e05c41
Merge remote-tracking branch 'elastic/master' into support-negative-s…
original-brownbear Sep 9, 2021
edf540f
Merge remote-tracking branch 'elastic/master' into support-negative-s…
original-brownbear Sep 9, 2021
fc296ed
tests
original-brownbear Sep 9, 2021
afa4afd
Merge remote-tracking branch 'elastic/master' into support-negative-s…
original-brownbear Sep 9, 2021
6f22652
Merge remote-tracking branch 'origin/support-negative-snapshot-patter…
original-brownbear Sep 9, 2021
60c9b81
Merge remote-tracking branch 'elastic/master' into support-negative-s…
original-brownbear Sep 10, 2021
bcecd6f
desired concrete name + wildcard behavior
original-brownbear Sep 10, 2021
ffe7484
_current is a wildcard pattern now
original-brownbear Sep 10, 2021
2110176
Merge remote-tracking branch 'elastic/master' into support-negative-s…
original-brownbear Sep 10, 2021
e7aa966
missing sentence
original-brownbear Sep 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 86 additions & 5 deletions docs/reference/snapshot-restore/apis/get-snapshot-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ Use the get snapshot API to return information about one or more snapshots, incl
`<repository>`::
(Required, string)
Comma-separated list of snapshot repository names used to limit the request.
Wildcard (`*`) expressions are supported.
Wildcard (`*`) expressions are supported including combining wildcards with exclude patterns starting with `-`.
+
To get information about all snapshot repositories registered in the
cluster, omit this parameter or use `*` or `_all`.

`<snapshot>`::
(Required, string)
Comma-separated list of snapshot names to retrieve. Also accepts wildcards (`*`).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still want to include this bit "Comma-separated list of snapshot names to retrieve. "?

Comma-separated list of snapshot names to retrieve. Also accepts wildcards (`*`) as well as combining wildcards and exclude patterns
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we align the text between repo and name match? Otherwise I end up searching for the difference between the text to understand if there is some difference...
Perhaps just state

Wildcard (`*`) expressions are supported including combining wildcards with exclude patterns starting with `-`

like above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that was pointless, made it the same for both as suggested now.

starting with `-`.
+
* To get information about all snapshots in a registered repository, use a wildcard (`*`) or `_all`.
* To get information about any snapshots that are currently running, use `_current`.
Expand Down Expand Up @@ -151,8 +152,8 @@ exclusive with using the `after` parameter. Defaults to `0`.
`slm_policy_filter`::
(Optional, string)
Filter snapshots by a comma-separated list of SLM policy names that snapshots belong to. Also accepts wildcards (`\*`) and combinations
of wildcards followed by exclude patterns starting in `-`. For example, the pattern `*,-policy-a-\*` will return all snapshots except
for those that were created by an SLM policy with a name starting in `policy-a-`. Note that the wildcard pattern `*` matches all snapshots
of wildcards followed by exclude patterns starting with `-`. For example, the pattern `*,-policy-a-\*` will return all snapshots except
for those that were created by an SLM policy with a name starting with `policy-a-`. Note that the wildcard pattern `*` matches all snapshots
created by an SLM policy but not those snapshots that were not created by an SLM policy. To include snapshots not created by an SLM
policy you can use the special pattern `_none` that will match all snapshots without an SLM policy.

Expand Down Expand Up @@ -546,4 +547,84 @@ The API returns the following response:
// TESTRESPONSE[s/"start_time_in_millis": 1593093628850/"start_time_in_millis": $body.snapshots.0.start_time_in_millis/]
// TESTRESPONSE[s/"end_time": "2020-07-06T21:55:18.129Z"/"end_time": $body.snapshots.0.end_time/]
// TESTRESPONSE[s/"end_time_in_millis": 1593094752018/"end_time_in_millis": $body.snapshots.0.end_time_in_millis/]
// TESTRESPONSE[s/"duration_in_millis": 0/"duration_in_millis": $body.snapshots.0.duration_in_millis/]
// TESTRESPONSE[s/"duration_in_millis": 0/"duration_in_millis": $body.snapshots.0.duration_in_millis/]

The following request returns information for all snapshots with prefix `snapshot` in the `my_repository` repository,
except for the one named `snapshot_3`

[source,console]
----
GET /_snapshot/my_repository/snapshot*,-snapshot_3?sort=name
----

The API returns the following response:

[source,console-result]
----
{
"snapshots": [
{
"snapshot": "snapshot_1",
"uuid": "dKb54xw67gvdRctLCxSket",
"repository": "my_repository",
"version_id": <version_id>,
"version": <version>,
"indices": [],
"data_streams": [],
"feature_states": [],
"include_global_state": true,
"state": "SUCCESS",
"start_time": "2020-07-06T21:55:18.129Z",
"start_time_in_millis": 1593093628850,
"end_time": "2020-07-06T21:55:18.129Z",
"end_time_in_millis": 1593094752018,
"duration_in_millis": 0,
"failures": [],
"shards": {
"total": 0,
"failed": 0,
"successful": 0
}
},
{
"snapshot": "snapshot_2",
"uuid": "vdRctLCxSketdKb54xw67g",
"repository": "my_repository",
"version_id": <version_id>,
"version": <version>,
"indices": [],
"data_streams": [],
"feature_states": [],
"include_global_state": true,
"state": "SUCCESS",
"start_time": "2020-07-06T21:55:18.130Z",
"start_time_in_millis": 1593093628851,
"end_time": "2020-07-06T21:55:18.130Z",
"end_time_in_millis": 1593094752019,
"duration_in_millis": 1,
"failures": [],
"shards": {
"total": 0,
"failed": 0,
"successful": 0
},
}
],
"total": 2,
"remaining": 0
}
----
// TESTRESPONSE[s/"uuid": "dKb54xw67gvdRctLCxSket"/"uuid": $body.snapshots.0.uuid/]
// TESTRESPONSE[s/"uuid": "vdRctLCxSketdKb54xw67g"/"uuid": $body.snapshots.1.uuid/]
// TESTRESPONSE[s/"version_id": <version_id>/"version_id": $body.snapshots.0.version_id/]
// TESTRESPONSE[s/"version": <version>/"version": $body.snapshots.0.version/]
// TESTRESPONSE[s/"start_time": "2020-07-06T21:55:18.129Z"/"start_time": $body.snapshots.0.start_time/]
// TESTRESPONSE[s/"start_time": "2020-07-06T21:55:18.130Z"/"start_time": $body.snapshots.1.start_time/]
// TESTRESPONSE[s/"start_time_in_millis": 1593093628850/"start_time_in_millis": $body.snapshots.0.start_time_in_millis/]
// TESTRESPONSE[s/"start_time_in_millis": 1593093628851/"start_time_in_millis": $body.snapshots.1.start_time_in_millis/]
// TESTRESPONSE[s/"end_time": "2020-07-06T21:55:18.129Z"/"end_time": $body.snapshots.0.end_time/]
// TESTRESPONSE[s/"end_time": "2020-07-06T21:55:18.130Z"/"end_time": $body.snapshots.1.end_time/]
// TESTRESPONSE[s/"end_time_in_millis": 1593094752018/"end_time_in_millis": $body.snapshots.0.end_time_in_millis/]
// TESTRESPONSE[s/"end_time_in_millis": 1593094752019/"end_time_in_millis": $body.snapshots.1.end_time_in_millis/]
// TESTRESPONSE[s/"duration_in_millis": 0/"duration_in_millis": $body.snapshots.0.duration_in_millis/]
// TESTRESPONSE[s/"duration_in_millis": 1/"duration_in_millis": $body.snapshots.1.duration_in_millis/]
Loading