-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Fix template not equals when setting does not start with "index." #83707
Conversation
hi, @martijnvg, @dakrone can you help to review this PR? |
Pinging @elastic/es-data-management (Team:Data Management) |
I'm not sure about this—on one hand the settings are functionally the same, however, when it comes to the actual structure of JSON and key names, they are not the same. Internally where is this template comparison causing problems? Can you explain where this pops up a bit more? |
It's the template equals case in our internal plugin, I found that the template I create is not equal to the template that I get from ClusterState. The test case: If it is not safe to modify the equals in the setting, I can add a settingsEquals in Template, like mappingsEquals. |
I don't think we should set this precedent, our internal tools should always be allowed to transform things as needed when they are added through the API. We have no guarantees for internal equals usage from plugins.
I think doing something like this in your plugin would be a better solution. Changing this behavior in the settings themselves is dangerous and I think will cause problems later down the road. We don't need an additional equals method in |
I change the logic from |
@elasticmachine update branch |
I still don't think we should do this in the template, as this is only a problem for plugins and does not affect the API. Out of curiosity, why can you not normalize/fix the index settings themselves before comparing templates in the first place? |
Yeah, we can do the same logic before execute put template action. But the create template logic change the setting of user input, and cause not equals problem. If it's not fixed now, we can see if the feature is needed later. |
When create template like this:
The setting does not start with "index.". But ClusterState will add the "index." prefix to the settings.
So the template don't equal the inner template.
In
MetadataIndexTemplateServiceTests.testAddComponentTemplate
, modify the setting like:It will cause the case failed.
I improve the
Settings.equals
, add the normalizePrefix to the settings before compare.I fixed two equals case in #77008 and #80864.
This PR is a new case.