Skip to content

Correctly handling data stream settings when component templates are used #130394

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

Merged

Conversation

masseyke
Copy link
Member

@masseyke masseyke commented Jul 1, 2025

If a composable template had no template structure of its own, and only used settings and mappings pulled in from component templates, then updating settings on a data stream built from that composable template could fail. For example:

// 1. create data stream that picks up the builtin `logs` template
POST logs-foo-bar/_doc
{
    "@timestamp": "2025-06-16"
}

// 2. set overrides
PUT _data_stream/logs-foo-bar/_settings
{
  "index.lifecycle.name": "foo",
  "index.lifecycle.prefer_ilm": true
}

// 3. unset overrides
PUT _data_stream/logs-foo-bar/_settings
{
  "index.lifecycle.name": null,
  "index.lifecycle.prefer_ilm": null
}

--->

{
  "data_streams": [
    {
      "name": "logs-foo-bar",
      "applied_to_data_stream": false,
      "error": """Cannot invoke "org.elasticsearch.cluster.metadata.Template.settings()" because the return value of "org.elasticsearch.cluster.metadata.ComposableIndexTemplate.template()" is null""",
      "settings": {},
      "effective_settings": {},
      "index_settings_results": {
        "applied_to_data_stream_only": [],
        "applied_to_data_stream_and_backing_indices": []
      }
    }
  ]
}

This change fixes this bug by correctly (and safely) resolving all settings for a data stream for validation, rather than only the ones from the top-level composable template.

@masseyke masseyke added >bug :Data Management/Data streams Data streams and their lifecycles auto-backport Automatically create backport pull requests when merged v8.19.0 v9.1.0 v9.2.0 labels Jul 1, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Jul 1, 2025
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

Hi @masseyke, I've created a changelog YAML for you.

@masseyke masseyke requested a review from lukewhiting July 1, 2025 14:37
Copy link
Contributor

@lukewhiting lukewhiting left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏻

@nielsbauman
Copy link
Contributor

I don't think we need to label this as >bug since none of these versions have been released, right? I'm mostly referring to the changelog here.

@masseyke
Copy link
Member Author

masseyke commented Jul 1, 2025

I don't think we need to label this as >bug since none of these versions have been released, right? I'm mostly referring to the changelog here.

Yeah, I initially labeled it as >non-issue and then added >bug for 9.1.0... and then remembered that we haven't actually released 9.1.0 yet. Removing the label now.

@masseyke masseyke added >non-issue and removed >bug labels Jul 1, 2025
@masseyke masseyke merged commit ae450da into elastic:main Jul 1, 2025
32 checks passed
@masseyke masseyke deleted the data-stream-settings-component-only-templates branch July 1, 2025 17:40
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.19 Commit could not be cherrypicked due to conflicts
9.1 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 130394

masseyke added a commit to masseyke/elasticsearch that referenced this pull request Jul 1, 2025
…used (elastic#130394)

(cherry picked from commit ae450da)

# Conflicts:
#	server/src/main/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsService.java
@masseyke
Copy link
Member Author

masseyke commented Jul 1, 2025

💚 All backports created successfully

Status Branch Result
9.1
8.19

Questions ?

Please refer to the Backport tool documentation

masseyke added a commit to masseyke/elasticsearch that referenced this pull request Jul 1, 2025
…used (elastic#130394)

(cherry picked from commit ae450da)

# Conflicts:
#	server/src/main/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsService.java
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jul 2, 2025
mridula-s109 pushed a commit to mridula-s109/elasticsearch that referenced this pull request Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged backport pending :Data Management/Data streams Data streams and their lifecycles >non-issue Team:Data Management Meta label for data/management team v8.19.0 v9.1.0 v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants