Skip to content

Conversation

@nielsbauman
Copy link
Contributor

We currently parse the request body of the PUT _data_stream/{name}/_lifecycle API in pretty much the same way as we parse DataStreamLifecycle objects. We currently already use the latter in the data stream options API.

By reusing that parser in this API too, we can remove some code and we'll automatically be able to parse new fields in this API when they get added to DataStreamLifecycle in the future. If there ever comes a point where there's a discrepancy between the two, we can always go back to having separate parsers.

@nielsbauman nielsbauman requested a review from masseyke November 30, 2025 07:44
@nielsbauman nielsbauman added >refactoring :Data Management/Data streams Data streams and their lifecycles labels Nov 30, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@elasticsearchmachine elasticsearchmachine added Team:Data Management Meta label for data/management team v9.3.0 labels Nov 30, 2025
Copy link
Member

@masseyke masseyke left a comment

Choose a reason for hiding this comment

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

This seems like a really good change to me. Tagging @gmarouli in case she knows of some reason we intentionally didn't do this in the first place.

@gmarouli
Copy link
Contributor

gmarouli commented Dec 2, 2025

I think it should work now. We used to have different parsers because in the the DataStreamLifecycle was accepting explicit null. Then we split it into two parsers the direct configuration and the template configuration. I believe it should work now.

@nielsbauman
Copy link
Contributor Author

Thanks for having a look, @gmarouli!

I indeed noticed that the parser in the API doesn't allow explicit null values. Is there a reason why we did that? By not allowing null values, we are preventing users from removing the retention and downsampling component. With this change, users will be able to remove those components. Is there a reason we didn't allow that before?

@gmarouli
Copy link
Contributor

gmarouli commented Dec 3, 2025

Is there a reason why we did that?

Explicit null values are not recommended in the api of elasticsearch, the absence of a value is enough to unset it. This is exactly how this API works as well, for example the following will unset the downsampling as you are mentioning:

{
   "data_retention": "3d"
}

The explicit null value has significance only in template composition, because we merge the component templates we do not override them. It is an exception to the general recommendation because it has different semantics.

@nielsbauman
Copy link
Contributor Author

Ahh right, I missed that somehow. Thanks for the explanation @gmarouli!

@nielsbauman nielsbauman merged commit f957556 into elastic:main Dec 3, 2025
34 checks passed
@nielsbauman nielsbauman deleted the put-dlm-lifecycle-parsing branch December 3, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/Data streams Data streams and their lifecycles >refactoring Team:Data Management Meta label for data/management team v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants