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

Add Clone Snapshot Request Handling Scaffolding #63037

Merged

Conversation

original-brownbear
Copy link
Member

Adds all the scaffolding for snapshot clone request handling
and index-to-clone resolution to reduce the diff in #61839 to
the bare essentials of the state machine changes for snapshot
cloning and relevant tests and give us the opportunity to
review the API in isolation.

Adds all the scaffolding for snapshot clone request handling
and index-to-clone resolution to reduce the diff in elastic#61839 to
the bare essentials of the state machine changes for snapshot
cloning and relevant tests and give us the opportunity to
review the API in isolation.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (:Distributed/Snapshot/Restore)

@elasticmachine elasticmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Sep 29, 2020
@tlrx tlrx self-requested a review September 30, 2020 07:39
private final String target;

// TODO: the current logic does not allow for specifying index resolution parameters like hidden and such. Do we care about cloning
// system or hidden indices?
Copy link
Member

Choose a reason for hiding this comment

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

Since hidden indices are included in snapshot by default (#57325) I think we should also allow them to be cloned and support IndicesOptions.

* @return list of index ids to clone
* @throws SnapshotException on failure to find concrete request index ids or any index ids
*/
static List<IndexId> findIndexIdsToClone(SnapshotId sourceSnapshotId, Snapshot targetSnapshot, RepositoryData repositoryData,
Copy link
Member

Choose a reason for hiding this comment

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

Can't we just reuse or adapt filterIndices() so that restore and clone indices parameter work the same?

Copy link
Member Author

Choose a reason for hiding this comment

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

🤦 yea let's do that and use IndicesOptions on the request, that makes it all fall into place much more nicely :) Thanks!

@original-brownbear
Copy link
Member Author

Thanks Tanguy, updated with your suggestions, this makes things a lot cleaner I think and also simplifies the other PR :)

@@ -659,6 +663,7 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster) {
registerHandler.accept(new RestCleanupRepositoryAction());
registerHandler.accept(new RestGetSnapshotsAction());
registerHandler.accept(new RestCreateSnapshotAction());
registerHandler.accept(new RestCloneSnapshotAction());
Copy link
Member

Choose a reason for hiding this comment

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

Can we comment this for now and only uncomment it once REST integration tests and the whole feature are done?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mainly made this active here to make sure our RestController can handle the shared path with the create-snapshot action. Turned it only accepts this if the parameter names are the same across both actions so I left it in place to make sure we don't break anything.
I'm only going to merge this to master before final completion anyway, so maybe we can just leave it?

Copy link
Member

Choose a reason for hiding this comment

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

Turned it only accepts this if the parameter names are the same across both actions so I left it in place to make sure we don't break anything.

Ok, I did not think about this. Let's keep it as it is and wait for the full feature to be done and merged before backporting it.


private String[] indices;

private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
Copy link
Member

Choose a reason for hiding this comment

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

Hidden indices are snapshotted by default so I think they should be cloned by default too? WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

I went with the defaults for restore here. I figured it's probably less likely that one would clone a hidden index so those seemed more natural?

Copy link
Member

Choose a reason for hiding this comment

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

Actually I'm more concerned about the following use case:
create a snapshot of all indices (it includes hidden ones) -> clone this snapshot and remove some large index I don't care anymore (it also removes hidden indices right?) -> delete the previous snapshot as I now have a lighter snapshot (but the hidden indices are gone silently)

or maybe I'm missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sold :), that's a conceivable use case for sure!

out.writeString(repository);
out.writeString(source);
out.writeString(target);
out.writeStringArray(indices);
Copy link
Member

Choose a reason for hiding this comment

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

Also serialize indices options

@original-brownbear
Copy link
Member Author

Thanks again Tanguy, sorry for all the noise in this one!

@original-brownbear
Copy link
Member Author

Jenkins run elasticsearch-ci/packaging-sample-windows

Copy link
Member

@tlrx tlrx left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Armin!

@original-brownbear
Copy link
Member Author

Thank you Tanguy!

@original-brownbear original-brownbear merged commit 45ba935 into elastic:master Sep 30, 2020
@original-brownbear original-brownbear deleted the clone-snapshot-api-2 branch September 30, 2020 11:32
original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request Oct 5, 2020
Adds all the scaffolding for snapshot clone request handling
and index-to-clone resolution to reduce the diff in elastic#61839 to
the bare essentials of the state machine changes for snapshot
cloning and relevant tests and give us the opportunity to
review the API in isolation.
original-brownbear added a commit that referenced this pull request Oct 5, 2020
Snapshot clone API. Complete except for some TODOs around documentation (and adding HLRC support).

backport of #61839, #63217, #63037
@original-brownbear original-brownbear restored the clone-snapshot-api-2 branch December 6, 2020 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >non-issue Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v7.10.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants