-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[ILM]: Fix TSDS unfollow timing with WaitUntilTimeSeriesEndTimePassesStep #128361
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
Changes from 8 commits
e45b2ef
731d62b
e759e97
4634388
99d6ecf
4f2845a
cb5e908
08fd178
47f2255
b053052
feab346
9598115
808af43
18bcd3d
1ad5d31
c0cc30e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| pr: 128361 | ||
| summary: The follower index should wait until the time series end time passes before unfollowing the leader index. | ||
| area: ILM+SLM | ||
| type: bug | ||
| issues: | ||
| - 128129 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,6 @@ | |
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
| import org.elasticsearch.client.Request; | ||
| import org.elasticsearch.client.RequestOptions; | ||
| import org.elasticsearch.client.Response; | ||
| import org.elasticsearch.client.ResponseException; | ||
| import org.elasticsearch.client.RestClient; | ||
|
|
@@ -571,7 +570,7 @@ public void testILMUnfollowFailsToRemoveRetentionLeases() throws Exception { | |
| } | ||
| } | ||
|
|
||
| @SuppressWarnings({ "checkstyle:LineLength", "unchecked" }) | ||
| @SuppressWarnings("unchecked") | ||
| public void testTsdbLeaderIndexRolloverAndSyncAfterWaitUntilEndTime() throws Exception { | ||
| String indexPattern = "tsdb-index-"; | ||
| String dataStream = "tsdb-index-cpu"; | ||
|
|
@@ -583,12 +582,12 @@ public void testTsdbLeaderIndexRolloverAndSyncAfterWaitUntilEndTime() throws Exc | |
| templateRequest.setJsonEntity(Strings.format(TSDB_INDEX_TEMPLATE, indexPattern, policyName)); | ||
| assertOK(client().performRequest(templateRequest)); | ||
| } else if ("follow".equals(targetCluster)) { | ||
| putILMPolicy(policyName, null, 1, null); | ||
| putUnfollowOnlyPolicy(client(), policyName); | ||
|
|
||
| Request createAutoFollowRequest = new Request("PUT", "/_ccr/auto_follow/tsdb_index_auto_follow_pattern"); | ||
| createAutoFollowRequest.setJsonEntity(""" | ||
| { | ||
| "leader_index_patterns": [ ".ds-tsdb-index-*" ], | ||
| "leader_index_patterns": [ "tsdb-index-*" ], | ||
| "remote_cluster": "leader_cluster", | ||
| "read_poll_timeout": "1000ms", | ||
| "follow_index_pattern": "{{leader_index}}" | ||
|
|
@@ -600,28 +599,19 @@ public void testTsdbLeaderIndexRolloverAndSyncAfterWaitUntilEndTime() throws Exc | |
| index(leaderClient, dataStream, "", "@timestamp", now, "volume", 11.0, "metricset", randomAlphaOfLength(5)); | ||
|
|
||
| String backingIndexName = getDataStreamBackingIndexNames(leaderClient, "tsdb-index-cpu").get(0); | ||
| assertBusy(() -> { assertOK(client().performRequest(new Request("HEAD", "/" + backingIndexName))); }); | ||
|
|
||
| // rollover | ||
| Request rolloverRequest = new Request("POST", "/" + dataStream + "/_rollover"); | ||
| rolloverRequest.setJsonEntity(""" | ||
| { | ||
| "conditions": { | ||
| "max_docs": "1" | ||
| } | ||
| }"""); | ||
| leaderClient.performRequest(rolloverRequest); | ||
|
||
| assertBusy(() -> assertOK(client().performRequest(new Request("HEAD", "/" + backingIndexName)))); | ||
|
|
||
| assertBusy(() -> { | ||
| Map<String, Object> indexExplanation = explainIndex(client(), backingIndexName); | ||
| assertThat( | ||
| "index must wait in the " + WaitUntilTimeSeriesEndTimePassesStep.NAME + " until its end time lapses", | ||
| explainIndex(client(), backingIndexName).get("step"), | ||
| indexExplanation.get("step"), | ||
| is(WaitUntilTimeSeriesEndTimePassesStep.NAME) | ||
| ); | ||
|
|
||
| assertThat(explainIndex(client(), backingIndexName).get("step_info"), is(notNullValue())); | ||
| assertThat(indexExplanation.get("step_info"), is(notNullValue())); | ||
| assertThat( | ||
| (String) ((Map<String, Object>) explainIndex(client(), backingIndexName).get("step_info")).get("message"), | ||
| (String) ((Map<String, Object>) indexExplanation.get("step_info")).get("message"), | ||
| containsString("Waiting until the index's time series end time lapses") | ||
| ); | ||
| }, 30, TimeUnit.SECONDS); | ||
|
|
@@ -967,15 +957,7 @@ private static String getShrinkIndexName(RestClient client, String originalIndex | |
| } | ||
|
|
||
| private static Map<String, Object> explainIndex(RestClient client, String indexName) throws IOException { | ||
| RequestOptions consumeWarningsOptions = RequestOptions.DEFAULT.toBuilder() | ||
| .setWarningsHandler(warnings -> warnings.isEmpty() == false && List.of(""" | ||
| [indices.lifecycle.rollover.only_if_has_documents] setting was deprecated in Elasticsearch \ | ||
| and will be removed in a future release. \ | ||
| See the deprecation documentation for the next major version.""").equals(warnings) == false) | ||
| .build(); | ||
|
|
||
| Request explainRequest = new Request("GET", indexName + "/_ilm/explain"); | ||
| explainRequest.setOptions(consumeWarningsOptions); | ||
| Response response = client.performRequest(explainRequest); | ||
| Map<String, Object> responseMap; | ||
| try (InputStream is = response.getEntity().getContent()) { | ||
|
|
@@ -991,7 +973,6 @@ private static int getDocCount(RestClient client, String indexName) throws IOExc | |
| Request countRequest = new Request("GET", "/" + indexName + "/_count"); | ||
| Response response = client.performRequest(countRequest); | ||
| Map<String, Object> result = entityAsMap(response); | ||
| System.out.println("result = " + result); | ||
| return (int) result.get("count"); | ||
| } | ||
| } | ||
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.
Similar here, could you add a comment to explain why we only want Unfollow action?