-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Flatten Get Snapshots Response #74451
Flatten Get Snapshots Response #74451
Conversation
Jenkins run elasticsearch-ci/docs (git ssh timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have only been through the non-test file changes for now. Mainly one comment needs attention: error handling.
.../src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsRequest.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java
Show resolved
Hide resolved
@@ -160,12 +172,12 @@ private void getMultipleReposSnapshotInfo( | |||
size, | |||
order, | |||
groupedActionListener.delegateResponse((groupedListener, e) -> { | |||
if (e instanceof ElasticsearchException) { | |||
groupedListener.onResponse(GetSnapshotsResponse.Response.error(repoName, (ElasticsearchException) e)); | |||
if (isMultiRepoRequest && e instanceof ElasticsearchException) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this way of error handling is new compared to elsewhere. I wonder if you considered one of following options:
- Respond with a failure if all repos failed (which would be the same as here in the single repo case). This is sort of similar to search.
- Breakingly never respond failures, expect users to look into the
failures
map. - Have an option to fail the request or send back failures in response.
Do we have other similar cases in ES we can lean on in order to decide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Respond with a failure if all repos failed (which would be the same as here in the single repo case). This is sort of similar to search.
That seems more complicated to work with than having the failures map? My thinking was to have the same behavior for all requests that target multiple repos. I'm somewhat indifferent here, making it look like search is nice, but in isolation I like this approach better I think.
Breakingly never respond failures, expect users to look into the failures map.
This is quite annoying to users perhaps (note that in 7.x we also have to think about the transport client behavior that would be changed by this). It may also be a troubling breaking change for Cloud? I'd rather not do this I think.
Have an option to fail the request or send back failures in response.
I don't think we have that kind of behavior anywhere else? Not sure it's worth the complexity for a very small number of use cases?
Do we have other similar cases in ES we can lean on in order to decide?
None come to mind for me that are similar enough but that doesn't mean there aren't any. I think I was in large part driven by not breaking the transport client API for users and cloud orchestration. In both cases changing the behavior for a single repo request seems risky?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this on another channel with following conclusion:
- We will merge this PR as is.
- We will follow-up with a PR to add the option to fail-fast or not, regardless of multi/single repo in regular breaking change style. The default in 7 will be fail fast, default in 8 will be always put it in array. Flag to be removed in 9.
server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java
Outdated
Show resolved
Hide resolved
Thanks @henningandersen all points addressed now I think :) |
Pinging @elastic/clients-team (Team:Clients) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor comments on the tests
assertThat(response.getSnapshots(), hasSize(2)); | ||
assertThat(response.getSnapshots().get(0).snapshotId().getName(), equalTo(snapshot1)); | ||
assertThat(response.getSnapshots().get(1).snapshotId().getName(), equalTo(snapshot2)); | ||
assertThat(response.getSnapshots().get(1).userMetadata(), equalTo(originalMetadata)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also validate that snapshot1 has repo1 and snapshot2 has repo2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes definitely, added that assertion :)
server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStatusApisIT.java
Outdated
Show resolved
Hide resolved
.peek(m -> logger.info("--> responses: {}", m)) | ||
.map(m -> (List<Map<String, Object>>) m.get("snapshots")) | ||
.peek(allReposSnapshots -> logger.info("--> all repository's snapshots: {}", allReposSnapshots)) | ||
.filter(allReposSnapshots -> allReposSnapshots.stream().anyMatch(repoHasSnapshot)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repoHasSnapshot
is now unused. I think it makes sense that this predicate is still validated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ removed it and checked the snapshot name prefix manually below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 2
Thanks so much Henning + Tanguy! |
This PR returns the get snapshots API to the 7.x format (and transport client behavior) and enhances it for requests that ask for multiple repositories. The changes for requests that target multiple repositories are: * Add `repository` field to `SnapshotInfo` and REST response * Add `failures` map alongside `snapshots` list instead of returning just an exception response as done for single repo requests * Pagination now works across repositories instead of being per repository for multi-repository requests closes elastic#69108 closes elastic#43462
) Backport of the recently introduced snapshot pagination and scalability improvements listed below. Merged as a single backport because the `7.x` and master snapshot status API logic had massively diverged between master and 7.x. With the work in the below PRs, the logic in master and 7.x once again has been aligned very closely again. #72842 #73172 #73199 #73570 #73952 #74236 #74451 (this one is only partly applicable as it was mainly a change to master to align `master` and `7.x` branches)
The group-by-repository response format is gone as a result of elastic#74451 => cleaning up its last remnants from REST tests.
The group-by-repository response format is gone as a result of #74451 => cleaning up its last remnants from REST tests.
This PR returns the get snapshots API to the 7.x format (and transport client behavior) and enhances it for requests that ask for multiple repositories.
The changes for requests that target multiple repositories are:
repository
field toSnapshotInfo
and REST responsefailures
map alongsidesnapshots
list instead of returning just an exception response as done for single repo requestscloses #69108
closes #43462