-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Support dependent validation for index settings #70144
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
Support dependent validation for index settings #70144
Conversation
A setting validator can declare settings that the validation depends on, but when updating index settings, we eagerly validate the settings before submitting the cluster state update and here we do not know the existing settings. With this commit, we ensure that the pre-validation works with such validators, letting the validator validate syntax (validate(value)) only. Relates elastic#70141.
Pinging @elastic/es-core-infra (Team:Core/Infra) |
After reading through this, I was surprised to learn about this With that said, I'm trying to understand more about why not validating dependent settings is necessary in this case.
Why would we not know all the settings? If we need to wait for a cluster state update, should the master be doing this validation and the update code should defer to that and trust the cluster state update will take care of it? Ultimately I'm concerned that adding more uses of an untested method will make it harder to cleanup the settings infrastructure, which is in dire need of some work. |
@rjernst thanks for looking into this. I believe you are right for a long term solution, we could certainly improve this. However, this needs to go into 7.12.0 and I think shaking the code too much is not the right choice there. The line causing this to fail for index settings with validators that depend on other settings is this: Line 82 in a92a647
where we validate most of the incoming settings. Then we validate some more inside the cluster state update. It is not entirely clear to me why we prevalidate the settings. If we remove that, the need for the There is a little bit of trickyness in removing it:
I will try to work on an alternative today. |
Index update settings does prevalidation primarily to ensure all keys are valid. With this change, we skip validating values during prevalidation, the final settings applied to each index are still validated in MetadataUpdateSettingsService.
AFAICS, we prevalidate the settings primarily to ensure the keys are valid before trying to apply it to all the indices. I went in the direction of disabling value validation for this prevalidation, alleviating your concern about the extra use of the This gives an error report of all illegal keys up front and then for the first failing index an error report of the illegal values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Henning! Changing this parameter to validateValues
makes a lot more sense to me, and I'm glad you were able to avoid using validateWithoutDependencies
. LGTM.
Thanks for the speedy review, Ryan. |
A setting validator can declare settings that the validation depends on, but when updating index settings, we eagerly validate the settings before submitting the cluster state update and here we do not know the existing settings. With this commit, we ensure that the pre-validation only validates the keys and not the values, leaving the value validation to after we have combined existing settings with the new settings on a per index basis.
A setting validator can declare settings that the validation depends on, but when updating index settings, we eagerly validate the settings before submitting the cluster state update and here we do not know the existing settings. With this commit, we ensure that the pre-validation only validates the keys and not the values, leaving the value validation to after we have combined existing settings with the new settings on a per index basis.
A setting validator can declare settings that the validation depends on, but when updating index settings, we eagerly validate the settings before submitting the cluster state update and here we do not know the existing settings. With this commit, we ensure that the pre-validation only validates the keys and not the values, leaving the value validation to after we have combined existing settings with the new settings on a per index basis.
A setting validator can declare settings that the validation depends on,
but when updating index settings, we eagerly validate the settings
before submitting the cluster state update and here we do not know the
existing settings. With this commit, we ensure that the pre-validation
works with such validators, letting the validator validate syntax
(validate(value)) only.
Relates #70141.