-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Allow for the data lifecycle to be explicitly nullified #95979
Conversation
Pinging @elastic/es-data-management (Team:Data Management) |
Hi @gmarouli, I've created a changelog YAML for you. |
Bumping the compatibility version of the failed tests. Since DLM is still experimental, I think we do not need to handle backwards compatibility. |
How would a user specify from a component template that the data stream should be unmanaged by DLM? |
Converted it to draft to add support for |
Bumping the compatibility version of the failed tests. Since DLM is still experimental, I think we do not need to handle backwards compatibility.
I am also doubting that part to be honest. Right now it is not possible. A component template might not have Should we change it and treat the same way? @dakrone is that what you had in mind? |
It's a little hard to reason about with prose, maybe a table will help us decide (the values in the table are the lifecycle config, assuming that
Hopefully that helps. Also, this is just some thoughts for discussion, not necessarily the way we have to decide. Either way, I think having the table is helpful to make sure we have the same thing in mind. What do you think? |
@dakrone thank you! This is indeed really helpful. I am going to make a table of the current composition in which explicit Current behavior: Table 1
Proposal # 1:
This means we extend the table above with the following cases: Table 2a
Proposal # 2:
This means we extend the table above with the following cases: Table 2b
My recommendation: @dakrone & @masseyke what do you think? Does this way of thinking stand? |
Thanks for presenting the proposals like this Mary — I favor proposal # 1 also. I think consistency is good to have no matter what kind of template. |
Your Table 1 has some conditions that aren't in Table 2a or 2b. I assume since null is not involved in those, the behavior would stay the same, right? |
Exactly, table 1 remains the same between the two proposals and depicts how composition works right now that we do not allow the
No worries, I can explain, there is precendence between the component template and the index template, so it works like this:
Does this make sense? If we do not do that any |
Oh OK -- I had thought that in proposal 1 you were removing that precedence. |
@elasticmachine update branch |
@elasticmachine run elasticsearch-ci/bwc |
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 for iterating on this Mary. This is shaping up nicely.
Left a few more comments
server/src/main/java/org/elasticsearch/cluster/metadata/DataLifecycle.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/DataLifecycle.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/Template.java
Outdated
Show resolved
Hide resolved
Waiting for: #96428 |
@elasticmachine update branch |
@elasticmachine update branch |
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 for iterating on this Mary.
Left a final batch of comments and this is almost ready 🚀
server/src/main/java/org/elasticsearch/cluster/metadata/DataLifecycle.java
Outdated
Show resolved
Hide resolved
@@ -180,7 +206,15 @@ public void writeTo(StreamOutput out) throws IOException { | |||
out.writeMap(this.aliases, StreamOutput::writeString, (stream, aliasMetadata) -> aliasMetadata.writeTo(stream)); | |||
} | |||
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_8_0) && DataLifecycle.isEnabled()) { | |||
out.writeOptionalWriteable(lifecycle); | |||
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_500_007)) { | |||
boolean isExplicitNull = NO_LIFECYCLE.equals(lifecycle); |
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 shouldn't use equals
here but ==
Should we also add a unit test that fails if equals
is used here?
@@ -1508,7 +1508,7 @@ public static DataLifecycle resolveLifecycle(ComposableIndexTemplate template, M | |||
public static DataLifecycle composeDataLifecycles(List<DataLifecycle> lifecycles) { | |||
DataLifecycle.Builder builder = null; | |||
for (DataLifecycle current : lifecycles) { | |||
if (current.equals(Template.NO_LIFECYCLE)) { | |||
if (current == Template.NO_LIFECYCLE) { |
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.
Should we add a test that fails if equals
is used here?
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.
Or maybe better just implement equals as follows:
@Override
public boolean equals(Object o) {
return this == o;
}
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.
Do you mean to throw an exception is someone is using equals
No, just a unit test that uses a DataLifecycle that is equals
to Template.NO_LIFECYCLE
(e.g the INFINITE_RETENTION one) and we compose it using composeDataLifecycles
and assert the correct result
This test would fail if we change the code to
if (current.equals(Template.NO_LIFECYCLE)) {
Hope that makes sense
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 think it does, let me try
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.
Ok, I am back, because both equals
and ==
behave the same in this case, I cannot really make a unit test fail, unless you had in mind to mock DataLifecycle
to ensure that equals is not called, but I am not sure we should go that far. If I am not mistaken, it's nicer to have ==
but since both are correct, I don't think we should go to such lengths. What do you think?
PS: the equals
fails because they are not the same class type.
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 equals fails because they are not the same class type
Ah, of course - the method override at instantiation time gives us this.
If we remove that override and somehow end up using equals
the testLifecycleComposition
test will fail (using ==
in the meantime makes us resilient to the method override removal)
I'm good 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.
LGTM, thanks for implementing this
@elasticmachine update branch |
These keys allow using an explicit `null` as the value to "unset" the configuration when merging multiple component templates. As related to the merging tables seen in elastic/elasticsearch#95979 (comment) Relates also to the discussion in elastic#2049
These keys allow using an explicit `null` as the value to "unset" the configuration when merging multiple component templates. As related to the merging tables seen in elastic/elasticsearch#95979 (comment) Relates also to the discussion in elastic#2049
In this PR we allow a template to have a
lifecycle
set tonull
. This can enable a user to explicitly signal that they do not want to use a lifecycle in a composable template even if the component templates havelifecycle
defined.In other words, we now support the following:
The above works in the following way:
lifecycle
.lifecycle
defined in the data streams created by this template.For example:
Part of: #93596