-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[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
[CCR] Move leader_index and leader_cluster parameters from resume follow to put follow api #34638
Conversation
…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.
Pinging @elastic/es-distributed |
@@ -31,14 +31,6 @@ protected boolean preserveClusterUponCompletion() { | |||
return true; | |||
} | |||
|
|||
public void testResumeFollow() { |
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.
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); |
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.
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 { |
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.
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()); |
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.
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.
…nd_cluster_parameters_from_resume_to_put_follow_api
…nd_cluster_parameters_from_resume_to_put_follow_api
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.
run gradle build tests |
…nd_cluster_parameters_from_resume_to_put_follow_api
…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.
…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.
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.