-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Fix ILM history index settings #61880
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
.../plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMHistoryTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.ilm; | ||
|
||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; | ||
import org.elasticsearch.action.admin.indices.get.GetIndexResponse; | ||
import org.elasticsearch.action.admin.indices.rollover.RolloverResponse; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.plugins.Plugin; | ||
import org.elasticsearch.test.ESIntegTestCase; | ||
import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin; | ||
import org.elasticsearch.xpack.core.XPackSettings; | ||
import org.elasticsearch.xpack.core.ilm.LifecyclePolicy; | ||
import org.elasticsearch.xpack.core.ilm.LifecycleSettings; | ||
import org.elasticsearch.xpack.core.ilm.action.PutLifecycleAction; | ||
import org.elasticsearch.xpack.ilm.history.ILMHistoryStore; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS; | ||
import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; | ||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; | ||
import static org.elasticsearch.xpack.core.ilm.LifecyclePolicyTestsUtils.randomTimeseriesLifecyclePolicy; | ||
import static org.hamcrest.Matchers.arrayContaining; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 1) | ||
public class ILMHistoryTests extends ESIntegTestCase { | ||
|
||
@Override | ||
protected Settings nodeSettings(int nodeOrdinal) { | ||
Settings.Builder settings = Settings.builder().put(super.nodeSettings(nodeOrdinal)); | ||
settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false); | ||
settings.put(XPackSettings.SECURITY_ENABLED.getKey(), false); | ||
settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false); | ||
settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false); | ||
settings.put(LifecycleSettings.LIFECYCLE_POLL_INTERVAL, "1s"); | ||
settings.put(LifecycleSettings.SLM_HISTORY_INDEX_ENABLED_SETTING.getKey(), false); | ||
return settings.build(); | ||
} | ||
|
||
@Override | ||
protected boolean ignoreExternalCluster() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
return Arrays.asList(LocalStateCompositeXPackPlugin.class, IndexLifecycle.class); | ||
} | ||
|
||
private void putTestPolicy() throws InterruptedException, java.util.concurrent.ExecutionException { | ||
LifecyclePolicy lifecyclePolicy = randomTimeseriesLifecyclePolicy("test"); | ||
PutLifecycleAction.Request putLifecycleRequest = new PutLifecycleAction.Request(lifecyclePolicy); | ||
PutLifecycleAction.Response putLifecycleResponse = client().execute(PutLifecycleAction.INSTANCE, putLifecycleRequest).get(); | ||
assertAcked(putLifecycleResponse); | ||
} | ||
|
||
public void testIlmHistoryIndexCanRollover() throws Exception { | ||
putTestPolicy(); | ||
Settings settings = Settings.builder().put(indexSettings()).put(SETTING_NUMBER_OF_SHARDS, 1) | ||
.put(SETTING_NUMBER_OF_REPLICAS, 0).put(LifecycleSettings.LIFECYCLE_NAME, "test").build(); | ||
CreateIndexResponse res = client().admin().indices().prepareCreate("test").setSettings(settings).get(); | ||
assertTrue(res.isAcknowledged()); | ||
|
||
assertBusy(() -> { | ||
String firstIndex = ILMHistoryStore.ILM_HISTORY_INDEX_PREFIX + "000001"; | ||
try { | ||
GetIndexResponse getIndexResponse = client().admin().indices().prepareGetIndex().setIndices(firstIndex).get(); | ||
assertThat(getIndexResponse.getIndices(), arrayContaining(firstIndex)); | ||
} catch (Exception e) { | ||
fail(e.getMessage()); | ||
} | ||
}); | ||
|
||
RolloverResponse rolloverResponse = client().admin().indices().prepareRolloverIndex(ILMHistoryStore.ILM_HISTORY_ALIAS).get(); | ||
String secondIndex = ILMHistoryStore.ILM_HISTORY_INDEX_PREFIX + "000002"; | ||
assertTrue(rolloverResponse.isAcknowledged()); | ||
assertThat(rolloverResponse.getNewIndex(), is(secondIndex)); | ||
|
||
GetIndexResponse getIndexResponse = client().admin().indices().prepareGetIndex().setIndices(secondIndex).get(); | ||
assertThat(getIndexResponse.getIndices(), arrayContaining(secondIndex)); | ||
|
||
//wait for all history items to index to avoid waiting for timeout in ILMHistoryStore beforeBulk | ||
Thread.sleep(6000); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why would
beforeBulk
timeout? would removing the policy from thetest
index and/or stopping ILM solve the issue of outstanding ilm-history entries? (we're manually rolling over theilm-history
alias so ILM is only needed to trigger the creation of the first history index)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've changed it, I stop ILM to reduce amount of history items to index and I wait for the ones that are created. It should be better than explicit wait. WDYT?