-
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
Add support for index pattern exclusion in CCR AutoFollow #72935
Add support for index pattern exclusion in CCR AutoFollow #72935
Conversation
af122b7
to
29119ef
Compare
1c76a5b
to
9ec9685
Compare
Pinging @elastic/es-distributed (Team:Distributed) |
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.
Thanks, this is looking good. I have a number of smaller comments only. I will request review from Tanguy too, since he authored auto-following initially.
.../rest-high-level/src/main/java/org/elasticsearch/client/ccr/PutAutoFollowPatternRequest.java
Outdated
Show resolved
Hide resolved
client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java
Outdated
Show resolved
Hide resolved
client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java
Outdated
Show resolved
Hide resolved
docs/reference/ccr/apis/auto-follow/get-auto-follow-pattern.asciidoc
Outdated
Show resolved
Hide resolved
docs/reference/ccr/apis/auto-follow/put-auto-follow-pattern.asciidoc
Outdated
Show resolved
Hide resolved
...n/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/PutAutoFollowPatternRequestTests.java
Outdated
Show resolved
Hide resolved
...n/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/PutAutoFollowPatternRequestTests.java
Outdated
Show resolved
Hide resolved
...c/test/java/org/elasticsearch/xpack/ccr/action/TransportPutAutoFollowPatternActionTests.java
Outdated
Show resolved
Hide resolved
...c/test/java/org/elasticsearch/xpack/ccr/action/TransportPutAutoFollowPatternActionTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/AutoFollowMetadata.java
Outdated
Show resolved
Hide resolved
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 left some minor comments and I agree with Henning's comments that should be addressed. Looks good o.w. 👍
assertBusy(() -> { | ||
assertThat(getNumberOfSuccessfulFollowedIndices(), equalTo(initialNumberOfSuccessfulFollowedIndices + 1)); | ||
}); |
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.
+1
I would also prefer to use a test specific prefix for the autofollow pattern name and inclusion/exclusion patterns (like testexcluions-*
) because all tests share the same cluster which is not cleaned up after a test case is executed. Using a test specific prefix helps to debug those when they fail.
x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowIT.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/ccr/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/ccr/auto_follow.yml
Show resolved
Hide resolved
docs/reference/ccr/apis/auto-follow/put-auto-follow-pattern.asciidoc
Outdated
Show resolved
Hide resolved
Thanks both for the review, I've addressed your comments. |
@@ -39,6 +39,7 @@ | |||
for (int i = 0; i < numPatterns; i++) { | |||
String remoteCluster = randomAlphaOfLength(4); | |||
List<String> leaderIndexPatterns = Collections.singletonList(randomAlphaOfLength(4)); | |||
List<String> leaderIndexExclusionsPatterns = Collections.singletonList(randomAlphaOfLength(4)); |
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.
Maybe randomize with empty, single and multiple exclusions patterns?
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.
Addressed in c531a60
@@ -84,6 +204,7 @@ | |||
body: | |||
remote_cluster: local | |||
leader_index_patterns: ['logs-*'] | |||
leader_index_exclusion_patterns: ['logs-excluded'] |
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 would have expected bwc tests to fail with this 🤔
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.
That's right, maybe for a PR we don't execute all the BWC test matrix? I'll remove the exclusion pattern in that test.
}); | ||
assertTrue(ESIntegTestCase.indexExists("copy-logs-201701", followerClient())); | ||
|
||
createLeaderIndex("logs-201801", leaderIndexSettings); |
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.
@fcofdez I don't think it is resolved, doesn't it?
final IndexMetadata leaderIndexMetadata = remoteMetadata.index(leaderIndexName); | ||
|
||
if (AutoFollowPattern.match(newLeaderPatterns, newLeaderIndexExclusionPatterns, indexAbstraction) == false) { | ||
logger.warn("The follower index {} for leader index {} does not match against the updated auto follow " + |
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'm a bit torn about this - I wonder if we should make it more explicit to the user by returning an error. The same question applies when inclusion patterns are updated - a follower index might previously match a pattern but not anymore. Maybe we should prevent such update and require either a new pattern to be created or the follower indices to be unfollowed first?
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 wasn't sure about what we wanted to do in these cases. I'm wondering if returning an error when a follower index was matching a previous pattern is a breaking change or not. In any case I think it's sensible to return an error in this scenario, I'll include it 👍.
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.
In any case I think it's sensible to return an error in this scenario, I'll include it +1.
Maybe wait for @henningandersen's opinion first
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 offline and we agreed that instead of emitting a warning or failing the request when an Auto-Follow patter is updated and previously configured follower indices don't match anymore we'll keep the current behaviour. Instead we'll improve the current docs.
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
--- | ||
"Test put and delete auto follow pattern with exclusion patterns": | ||
- skip: | ||
version: " - 7.13.99" |
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'm surprised this test passed when executed against the 7.x branch 🤔
...cr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutAutoFollowPatternAction.java
Outdated
Show resolved
Hide resolved
Thanks Tanguy and Henning! |
This commit adds the ability to specify exclusion patterns in Auto-Follow patterns. This allows excluding indices that match any of the inclusion patterns and also match some of the exclusion patterns giving more fine grained control in scenarios where this is important. Related elastic#67686 Backport of elastic#72935
This commit adds the ability to specify exclusion patterns in Auto-Follow patterns. This allows excluding indices that match any of the inclusion patterns and also match some of the exclusion patterns giving more fine grained control in scenarios where this is important. Related #67686 Backport of #72935
…llowed Use an empty ClusterState as a base cluster state for that test Closes elastic#73797 Relates elastic#72935
…llowed Use an empty ClusterState as a base cluster state to take into account the case where no leader candidate indices are created Closes elastic#73797 Relates elastic#72935 Backport of elastic#73811
This pull request adds the ability to specify exclusion patterns for Auto-Follow patterns. This allows excluding indices that match any of the inclusion patterns and also match some of the exclusion patterns giving more fine grained control in scenarios where this is important.
Related #67686