Skip to content
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

Use data stream for ILM history #60280

Closed
wants to merge 32 commits into from

Conversation

probakowski
Copy link
Contributor

This change moves ILM history from using normal index and legacy template to data streams and composable templates.
It also unmutes several ITs to check if using data streams will resolve some race conditions there.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/ILM+SLM)

@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Jul 28, 2020
Copy link
Contributor

@andreidan andreidan left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @probakowski

Left a few comments

@@ -59,7 +53,6 @@
public class ILMHistoryStore implements Closeable {
private static final Logger logger = LogManager.getLogger(ILMHistoryStore.class);

public static final String ILM_HISTORY_INDEX_PREFIX = "ilm-history-" + INDEX_TEMPLATE_VERSION + "-";
public static final String ILM_HISTORY_ALIAS = "ilm-history-" + INDEX_TEMPLATE_VERSION;
Copy link
Contributor

Choose a reason for hiding this comment

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

should we rename this to _DATA_STREAM ?

.filter(BulkItemResponse::isFailed)
.collect(Collectors.toMap(BulkItemResponse::getId, BulkItemResponse::getFailureMessage));
logger.error("failures: [{}]", failures);
.map(r->r.getFailure().getCause())
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we should change the way we report errors. eg. could the failure cause be null ever? if so addSuppressed would fail. I think we should keep the BulkItemResponse#getFailureMessage as the reported error.
What do you think?

// The index didn't exist before we made the call, there was probably a race - just ignore this
logger.debug("index [{}] was created after checking for its existence, likely due to a concurrent call",
initialHistoryIndexName);
if(e instanceof IllegalArgumentException && e.getMessage().contains("exists")){
Copy link
Contributor

Choose a reason for hiding this comment

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

should we maybe probe the error message to be an exact match? ie. data_stream [ilm-history-3] already exists (with corresponding parameterized data stream name)
I wonder why we're not throwing ResourceAlreadyExists in the data stream case too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Changed this to throw ResourceAlreadyExistsException in #60518

@@ -229,85 +218,21 @@ public void testHistoryIndexProperlyExistsAlready() throws InterruptedException
ElasticsearchAssertions.awaitLatch(latch, 10, TimeUnit.SECONDS);
}

public void testHistoryIndexHasNoWriteIndex() throws InterruptedException {
Copy link
Contributor

Choose a reason for hiding this comment

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

pretty neat we can get rid of these edge cases 🎉

@dakrone
Copy link
Member

dakrone commented Aug 3, 2020

So I have a thought about this. We recently were discussing adding an API to migrate a set on indices (with an alias) into a data stream. Do we know if Kibana can correctly handle the scenario where ilm-history-1 and/or ilm-history-2 is an alias pointing to a set of indices while ilm-history-3 is a data stream? If it can't, does it make sense to wait until we have the translation API so they can all be data streams at the same time?

Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

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

I left some comments, thanks for changing this Przemko!

},
"priority": 2147483647,
"version": ${xpack.ilm_history.template.version}
Copy link
Member

Choose a reason for hiding this comment

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

Since we support _meta here now, can we add:

"_meta": {
  "managed": true,
  "description": "index template for ILM indices indices"
}

So that the UI can mark this accordingly?

.setWaitForActiveShards(1)
.addAlias(new Alias(ILM_HISTORY_ALIAS).writeIndex(true).isHidden(true))
.execute(new ActionListener<>() {
static void ensureHistoryDataStream(Client client, ClusterState state, ActionListener<Boolean> listener) {
Copy link
Member

Choose a reason for hiding this comment

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

So I think we should remove this entirely, part of the reason we have data streams now is to not have to pre set up anything before indexing. Now that we wouldn't use aliases we don't have the complicated alias setup that requires us checking this every time.

@probakowski
Copy link
Contributor Author

@elasticmachine update branch

@probakowski
Copy link
Contributor Author

@elasticmachine update branch

@probakowski
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/2

@probakowski
Copy link
Contributor Author

@elasticmachine update branch

@probakowski
Copy link
Contributor Author

@elasticmachine update branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/ILM+SLM Index and Snapshot lifecycle management >enhancement Team:Data Management Meta label for data/management team v7.11.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants