Excluding system data streams from global and factory retention#108038
Conversation
|
Hi @masseyke, I've created a changelog YAML for you. |
…ithub.com:masseyke/elasticsearch into exclude-system-data-streams-from-global-retention
nielsbauman
left a comment
There was a problem hiding this comment.
I know this is just a draft, but I placed some comments anyway, as I was afraid I'd forget them otherwise 😄. Hopefully, there's not too much overlap with what you were already planning on doing but just hadn't come around to yet.
server/src/main/java/org/elasticsearch/cluster/metadata/ComponentTemplate.java
Outdated
Show resolved
Hide resolved
...ain/java/org/elasticsearch/action/datastreams/lifecycle/ExplainIndexDataStreamLifecycle.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/Template.java
Outdated
Show resolved
Hide resolved
| for (String label : rolloverConfiguration.resolveRolloverConditions( | ||
| lifecycle.getEffectiveDataRetention(globalRetention, randomBoolean()) | ||
| ).getConditions().keySet()) { |
There was a problem hiding this comment.
Maybe we can extract the rollover conditions to a variable to make this a bit more readable? Same goes for the other changes in tests.
server/src/test/java/org/elasticsearch/cluster/metadata/ComposableIndexTemplateTests.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/cluster/metadata/ComposableIndexTemplateTests.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleTests.java
Show resolved
Hide resolved
…ithub.com:masseyke/elasticsearch into exclude-system-data-streams-from-global-retention
… retention for calcuating rollover for display
server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamLifecycle.java
Outdated
Show resolved
Hide resolved
| if (in.getTransportVersion().onOrAfter(TransportVersions.NO_LIFECYCLE_FOR_SYSTEM_DATA_STREAMS)) { | ||
| this.isSystemDataStream = in.readBoolean(); | ||
| } else { | ||
| this.isSystemDataStream = false; | ||
| } |
There was a problem hiding this comment.
Nit:
| if (in.getTransportVersion().onOrAfter(TransportVersions.NO_LIFECYCLE_FOR_SYSTEM_DATA_STREAMS)) { | |
| this.isSystemDataStream = in.readBoolean(); | |
| } else { | |
| this.isSystemDataStream = false; | |
| } | |
| this.isSystemDataStream = in.getTransportVersion().onOrAfter(TransportVersions.NO_LIFECYCLE_FOR_SYSTEM_DATA_STREAMS)) && in.readBoolean(); |
There was a problem hiding this comment.
I kind of like the simplicity of the if/else here. That's just a matter of personal preference, right? The outcome is the same either way?
There was a problem hiding this comment.
I'd argue that the one-liner is just as simple 😛. But it's definitely just personal preference as I've seen both variations and the outcome is the same. I'm fine with leaving it like this if that's your preference.
server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamLifecycleTests.java
Outdated
Show resolved
Hide resolved
|
Pinging @elastic/es-data-management (Team:Data Management) |
nielsbauman
left a comment
There was a problem hiding this comment.
Some last comments form my side, after those we'll be good to go :)
| assertThat(dataStream.newEffectiveRetention(), equalTo(globalRetention.getMaxRetention())); | ||
| } else { | ||
| assertThat(affectedDataStreams.size(), is(1)); | ||
| var dataStream = affectedDataStreams.get(1); |
There was a problem hiding this comment.
This is going to give an IndexOutOfBoundsException.
There was a problem hiding this comment.
Oops. Not sure how I missed that!
| public void testSystemExplainLifecycle() throws Exception { | ||
| /* | ||
| * This test makes sure that for system data streams, we correctly ignore the global retention when calling | ||
| * ExplainDataStreamLifecycle. It is very simila to testExplainLifecycle, but only focuses on the retention for a system index. |
There was a problem hiding this comment.
Nit:
| * ExplainDataStreamLifecycle. It is very simila to testExplainLifecycle, but only focuses on the retention for a system index. | |
| * ExplainDataStreamLifecycle. It is very similar to testExplainLifecycle, but only focuses on the retention for a system index. |
| public static final TransportVersion SECURITY_ROLE_MAPPINGS_IN_CLUSTER_STATE = def(8_647_00_0); | ||
| public static final TransportVersion ESQL_REQUEST_TABLES = def(8_648_00_0); | ||
| public static final TransportVersion ROLE_REMOTE_CLUSTER_PRIVS = def(8_649_00_0); | ||
| public static final TransportVersion NO_LIFECYCLE_FOR_SYSTEM_DATA_STREAMS = def(8_650_00_0); |
There was a problem hiding this comment.
Nit:
| public static final TransportVersion NO_LIFECYCLE_FOR_SYSTEM_DATA_STREAMS = def(8_650_00_0); | |
| public static final TransportVersion NO_GLOBAL_RETENTION_FOR_SYSTEM_DATA_STREAMS = def(8_650_00_0); |
| assertThat( | ||
| explainIndex.getLifecycle().getDataStreamRetention(), | ||
| equalTo(TimeValue.timeValueDays(SYSTEM_DATA_STREAM_RETENTION_DAYS)) | ||
| ); |
There was a problem hiding this comment.
Isn't this test missing a request that actually sets a global retention? Without such a request, this assertion becomes rather trivial, I think. But maybe I'm missing something.
nielsbauman
left a comment
There was a problem hiding this comment.
LGTM! Thanks for iterating on this Keith :)
We have the notion of global and factory retention for data streams, where we declare the default and maximum retention for all data streams. However, we don't want system data streams to be constrained by these. For example, some system data streams will need to have unlimited retention. This PR makes it so that system data streams are not affected by global or factory data stream retention.