elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.82k stars 24.71k forks source link

Index settings are incorrectly set to `null` when the setting is set by an index template #86786

Open romain-chanu opened 2 years ago

romain-chanu commented 2 years ago

Elasticsearch Version

7.17.3

Installed Plugins

No response

Java Version

bundled

OS Version

Deployment in ESS

Problem Description

Index settings are incorrectly set to null when the setting is set by an index template.

Take the below situation (observed in the field). While this may not be logical, we should provide better resilience or safety to avoid this kind of situation.

1) User can create a legacy template with the following definition:

PUT _template/default
{
  "order": -1,
  "index_patterns": [
    "*"
  ],
  "settings": {
    "index": {
      "routing": {
        "allocation": {
          "require": {
            "data": null
          }
        }
      }
    }
  },
  "mappings": {},
  "aliases": {}
}

2) An index myindex is created (e.g PUT myindex).

3) Checking the index settings of myindex (GET myindex/_settings), we observe that index.routing.allocation.require is set to null

{
  "myindex" : {
    "settings" : {
      "index" : {
        "routing" : {
          "allocation" : {
            "include" : {
              "_tier_preference" : "data_content"
            },
            "require" : {
              "data" : null
            }
          }
        },
        "number_of_shards" : "1",
        "provided_name" : "myindex",
        "creation_date" : "1652497877861",
        "number_of_replicas" : "1",
        "uuid" : "dT-AU9czQTmoZIBcdydB1A",
        "version" : {
          "created" : "7170399"
        }
      }
    }
  }
}

Steps to Reproduce

As described above. This also happens in version 8.2.0 as well.

Logs (if relevant)

No response

elasticmachine commented 2 years ago

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