Validate index settings after applying templates #44612
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Today we validate index settings before applying templates. While this does not cause a problem in general (since if there is a problem we will end up failing on index creation anyway), there is one case where it does cause a problem: checking whether or not the index creation will bring the cluster over the shard limit per node. This is because the only time this limit is checked is when index settings are validated. If we are doing this before applying templates, we would not have the correct number of shards used to check the limit. This commit addresses this by first applying templtes before validating index settings. This addresses the case of checking the shard limit per node, but also will help prevent additional bugs like this in the future. Note that we can not add in any private settings until after the validation is done (otherwise they will fail validation).
Closes #44567
Relates #34021