Skip to content
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

Rollover API failing with 400 in case settings name don't have "index." prefix or "index" section in json #53388

Closed
shwetathareja opened this issue Mar 11, 2020 · 7 comments
Labels
:Data Management/ILM+SLM Index and Snapshot lifecycle management >regression Team:Data Management Meta label for data/management team v7.9.0 v8.0.0-alpha1

Comments

@shwetathareja
Copy link

Elasticsearch version (bin/elasticsearch --version): 7.6

Plugins installed: []

Description of the problem including expected versus actual behavior:
Rollover API takes index settings as input parameters. The settings can specified as one of the below options:

1.  "settings": {
      "index" : {
    	"number_of_shards": 2
      }
  }
 2.  "settings": {
    "index.number_of_shards": 2
  }
3. "settings": {
    "number_of_shards": 2
  }

But, with this PR. the #3 option doesn't work and throws error as

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "unknown setting [number_of_shards] did you mean [index.number_of_shards]?"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "unknown setting [number_of_shards] did you mean [index.number_of_shards]?"
  },
  "status" : 400
}

Fix:
There is normalize and settings validation logic in onlyCreateIndex method and after refactoring this code is not getting triggered during rollover flow which calls applyCreateIndexRequest method.

Settings.Builder updatedSettingsBuilder = Settings.builder();
        Settings build = updatedSettingsBuilder.put(request.settings()).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX).build();
        indexScopedSettings.validate(build, true); // we do validate here - index setting must be consistent
        request.settings(build);

The normalize call should also run during rollover flow otherwise it breaks the expected behavior.

Steps to reproduce:

1. curl -XPUT localhost:9200/abc-000001
2. curl -XPUT localhost:9200/abc-000001/_alias/abc
3. curl -X POST "localhost:9200/abc/_rollover?pretty" -H 'Content-Type: application/json' -d'
{
"conditions": {
"max_age":   "1s"
},
"settings": {
"number_of_shards": 2
}
}
'

Tried running this in 7.5 with no issue and rollover works as expected.

@matriv matriv added the :Data Management/ILM+SLM Index and Snapshot lifecycle management label Mar 11, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/ILM+SLM)

@shwetathareja
Copy link
Author

Hi Team,

If we are aligned on the issue and the fix. I can pick it up.

@andreidan
Copy link
Contributor

Thanks for using ILM and reporting this bug @shwetathareja
Feel free to work on a fix for this and let us know if you need any help.

@jimczi jimczi removed the v7.6.2 label Mar 18, 2020
@shwetathareja
Copy link
Author

Sure andreidan@, Sorry for the delay. I will pick it up.

@bpintea bpintea added v7.8.0 and removed v7.7.0 labels Mar 25, 2020
@rjernst rjernst added the Team:Data Management Meta label for data/management team label May 4, 2020
@Gaurav614
Copy link
Contributor

Talked to @shwetathareja about this opened issue and wanted to pickup the implementation of it.
I will start working on this issue and will raise the PR for it shortly

Gaurav614 added a commit to Gaurav614/elasticsearch that referenced this issue May 28, 2020
It fixes the issue elastic#53388
by normalizing prefix at index creation request itself
dakrone pushed a commit that referenced this issue Jun 16, 2020
Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Lee Hinman <[email protected]>

It fixes the issue #53388
by normalizing prefix at index creation request itself
dakrone pushed a commit to dakrone/elasticsearch that referenced this issue Jun 16, 2020
Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Lee Hinman <[email protected]>

It fixes the issue elastic#53388
by normalizing prefix at index creation request itself
dakrone added a commit that referenced this issue Jun 16, 2020
* Normalized prefix for rollover API (#57271)

Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Lee Hinman <[email protected]>

It fixes the issue #53388
by normalizing prefix at index creation request itself

* Fix compilation for backport

Co-authored-by: Gaurav Chandani <[email protected]>
@pugnascotia
Copy link
Contributor

Closed by #57271.

@jbaiera
Copy link
Member

jbaiera commented Nov 5, 2020

Closing for real this time

@jbaiera jbaiera closed this as completed Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/ILM+SLM Index and Snapshot lifecycle management >regression Team:Data Management Meta label for data/management team v7.9.0 v8.0.0-alpha1
Projects
None yet
Development

No branches or pull requests