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

Continue to accept unused 'universal' params in <8.0 indexes #59381

Merged
merged 3 commits into from
Jul 13, 2020

Conversation

romseygeek
Copy link
Contributor

We have a number of parameters which are universally parsed by almost all
mappers, whether or not they make sense. Migrating the binary and boolean
mappers to the new style of declaring their parameters explicitly has meant
that these universal parameters stopped being accepted, which would break
existing mappings.

This commit adds some extra logic to ParametrizedFieldMapper that checks
for the existence of these universal parameters, and issues a warning on
7x indexes if it finds them. Indexes created in 8.0 and beyond will throw an
error.

Fixes #59359

@romseygeek romseygeek added >breaking :Search Foundations/Mapping Index mappings, including merging and defining field types v8.0.0 v7.9.0 labels Jul 13, 2020
@romseygeek romseygeek self-assigned this Jul 13, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jul 13, 2020
Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, the only doubt I have is around using the index created version for these checks, but I assume that this is how we do it in other places around mappings and that should be ok.

@@ -330,6 +335,12 @@ public final void parse(String name, TypeParser.ParserContext parserContext, Map
}
Parameter<?> parameter = paramsMap.get(propName);
if (parameter == null) {
if (checkForDeprecatedParameter(propName, parserContext.indexVersionCreated())) {
deprecationLogger.deprecate(propName,
"Parameter [{}] is unused on type [{}] and will be removed in future", propName, type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe saying "has no effect" would be clearer to users?

private static final Set<String> DEPRECATED_PARAMS
= Set.of("store", "meta", "index", "doc_values", "boost", "index_options", "similarity");

private boolean checkForDeprecatedParameter(String propName, Version indexCreatedVersion) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be static?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also should we rename to isDeprecatedParameter? I find check more ambiguous in what it does.

@romseygeek
Copy link
Contributor Author

the only doubt I have is around using the index created version for these checks, but I assume that this is how we do it in other places around mappings and that should be ok.

Yes, the idea is that we shouldn't fail to open an index that had its mappings configured without any problems in an earlier version of ES.

@javanna
Copy link
Member

javanna commented Jul 13, 2020

@romseygeek is this a breaking change alone? Possibly the introduction of parameterized field mapper was instead?

@romseygeek
Copy link
Contributor Author

Yeah, #58663 is the actual breaking change - I'll remove the tag from this issue and put it on that one instead. Thanks!

@romseygeek
Copy link
Contributor Author

@elasticmachine update branch

@romseygeek romseygeek merged commit 3363048 into elastic:master Jul 13, 2020
@romseygeek romseygeek deleted the bug/deprecated-params branch July 13, 2020 10:08
romseygeek added a commit that referenced this pull request Jul 13, 2020
We have a number of parameters which are universally parsed by almost all
mappers, whether or not they make sense. Migrating the binary and boolean
mappers to the new style of declaring their parameters explicitly has meant
that these universal parameters stopped being accepted, which would break
existing mappings.

This commit adds some extra logic to ParametrizedFieldMapper that checks
for the existence of these universal parameters, and issues a warning on
7x indexes if it finds them. Indexes created in 8.0 and beyond will throw an
error.

Fixes #59359
@cjcenizal
Copy link
Contributor

@romseygeek I'm trying to understand how this work affects the mappings editor UI in Kibana. This editor provides a form for configuring the parameters of each mapping type. We need a list of the acceptable parameters for each mapping type in order to make sure the forms accurately represent each type's parameters. Could you link to the documentation that makes these parameters explicit for the mappings types you've touched, or clarify your changes in the PR description? Thanks!

@romseygeek
Copy link
Contributor Author

@cjcenizal in each case I'm checking the set of parameters for a field mapper against its existing documentation page. The set of parameters mentioned in this PR are ones that were automatically parsed, but either had no effect or only had a single allowed value, so we wouldn't want them exposed in the mappings editor in any case.

@cjcenizal
Copy link
Contributor

@romseygeek Thanks for explaining! To be clear, I'm just looking for an explicit list of which parameters now issue warnings, and for which field types. Could you write that down for me or direct me to somewhere it is written down (e.g. docs)?

@cjcenizal
Copy link
Contributor

I chatted with Alan about this over Zoom and he cleared things up for me. Some fields used to accept undocumented parameters, which they would silently accept. The code has been changed so that these fields still accept the undocumented parameters (which remain undocumented), except now a deprecation warning is issued so that consumers will be notified that they'll be rejected in the future.

The net result is that the contract created by the docs hasn't changed, so code built upon this contract (as we did with mappings editor) will still work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v7.9.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parametrized mapper should not fail on silently unsupported parameters
5 participants