Skip to content

[CCR] Move leader_index and leader_cluster parameters from resume follow to put follow api #34638

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

Conversation

martijnvg
Copy link
Member

As part of this change the leader index name and leader cluster name are
stored in the CCR metadata in the follow index. The resume follow api
will read that when a resume follow request is executed.

…low to put follow api

As part of this change the leader index name and leader cluster name are
stored in the CCR metadata in the follow index. The resume follow api
will read that when a resume follow request is executed.
@martijnvg martijnvg added >non-issue :Distributed Indexing/CCR Issues around the Cross Cluster State Replication features labels Oct 19, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@@ -31,14 +31,6 @@ protected boolean preserveClusterUponCompletion() {
return true;
}

public void testResumeFollow() {
Copy link
Member Author

Choose a reason for hiding this comment

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

The resume api now looks up the follow index metadata in order to get the leader index name and leader cluster name and because of that this fails with a different error. We can't execute a put follow to create the follow index, because the leader cluster runs with a basic license. So I don't see a way how to test this in another way.

assertThat(e.getMessage(), containsString("insufficient privileges to follow index [unallowed-index], " +
"privilege for action [indices:monitor/stats] is missing, " +
"privilege for action [indices:data/read/xpack/ccr/shard_changes] is missing"));
// Verify that the follow index has not been created and no node tasks are running
assertThat(indexExists(adminClient(), unallowedIndex), is(false));
assertBusy(() -> assertThat(countCcrNodeTasks(), equalTo(0)));

e = expectThrows(ResponseException.class, () -> resumeFollow(unallowedIndex, unallowedIndex));
follow(adminClient(), unallowedIndex, unallowedIndex);
Copy link
Member Author

Choose a reason for hiding this comment

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

Execute put follow api with admin client, so that we can check whether we fail with the right error when a normal user resumes following an unallowed index.

@@ -427,37 +421,11 @@ public void testFollowIndexMaxOperationSizeInBytes() throws Exception {
assertTotalNumberOfOptimizedIndexing(resolveFollowerIndex("index2"), 1, numDocs);
}

public void testDontFollowTheWrongIndex() throws Exception {
Copy link
Member Author

Choose a reason for hiding this comment

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

It is no longer possible to supply a leader index to the resume follow api and therefor this test is no longer needed. Prior this change you could specify a different leader index / cluster than was specified in put follow api or prior follow resume api calls.

@@ -159,6 +158,8 @@ public ClusterState execute(final ClusterState currentState) throws Exception {
Map<String, String> metadata = new HashMap<>();
metadata.put(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_SHARD_HISTORY_UUIDS, String.join(",", historyUUIDs));
metadata.put(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_UUID_KEY, leaderIndexMetaData.getIndexUUID());
metadata.put(Ccr.CCR_CUSTOM_METADATA_LEADER_INDEX_NAME_KEY, leaderIndexMetaData.getIndex().getName());
metadata.put(Ccr.CCR_CUSTOM_METADATA_LEADER_CLUSTER_NAME_KEY, request.getLeaderCluster());
Copy link
Member Author

Choose a reason for hiding this comment

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

By remember this two additional key value pairs the resume api no longer needs to accept a leader index / cluster parameters.

The leader index name isn't really necessary as the leader index uuid can also be used to lookup the leader index metadata in the leader cluster. The CcrLicenseChecker#checkRemoteClusterLicenseAndFetchLeaderIndexMetadataAndHistoryUUIDs(...) only accepts a leader index name now. Put follow api also uses this method and that would mean I another version of this method is needed to knows how to work with index uuid. I found that this would make CcrLicenseChecker too complicated, so I decided to remember the leader index name inside ccr custom index metadata instead.

@martijnvg martijnvg requested a review from jasontedor October 19, 2018 13:55
Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

LGTM.

@martijnvg
Copy link
Member Author

run gradle build tests

…nd_cluster_parameters_from_resume_to_put_follow_api
@martijnvg martijnvg merged commit ed817fb into elastic:master Oct 23, 2018
martijnvg added a commit that referenced this pull request Oct 23, 2018
…low to put follow api (#34638)

As part of this change the leader index name and leader cluster name are
stored in the CCR metadata in the follow index. The resume follow api
will read that when a resume follow request is executed.
kcm pushed a commit that referenced this pull request Oct 30, 2018
…low to put follow api (#34638)

As part of this change the leader index name and leader cluster name are
stored in the CCR metadata in the follow index. The resume follow api
will read that when a resume follow request is executed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Indexing/CCR Issues around the Cross Cluster State Replication features >non-issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants