-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Adding a deprecation info api check for custom types in templates #80676
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
Adding a deprecation info api check for custom types in templates #80676
Conversation
Pinging @elastic/es-data-management (Team:Data Management) |
EDIT: spoke with Keith and think ^^ is incorrect since custom types require a HTTP parameter ( |
@jtibshirani - Would you mind also reviewing this PR ? I seem to recall some creative use |
I'd definitely appreciate an additional review because I'm not incredibly familiar with this. For what it's worth in addition to the unit tests I added, I tested this by posting 3 templates to "_template" on a 7.16.0 server -- (1) no type, not returned by this check, (2) a type called "someType", not returned by this check, and (3) a type called "_doc", not returned by this check. |
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.
This makes sense to me, based on my memory of how these templates are stored.
state.getMetadata().getTemplates().forEach((templateCursor) -> { | ||
String templateName = templateCursor.key; | ||
ImmutableOpenMap<String, CompressedXContent> mappings = templateCursor.value.mappings(); | ||
if (mappings != null && mappings.size() == 1) { |
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.
I think we should check the type name even if there is more than one mapping type. For example, a user could have both a _default_
mapping and a custom one like some_type
.
This makes me think -- maybe this check could be combined with the one above checkTemplatesWithMultipleTypes
? That way we could report all errors at once (both that they are using a _default_
mapping, and that they have an custom type name). The error message about "multiple types" could be improved to talk about a _default_
mapping to be more specific.
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.
I was only checking for single mapping types with the thought that checkTemplatesWithMultipleTypes would catch the others. I'll see if I can find a clean way to combine them.
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.
My earlier comment was based on a misunderstanding -- I thought you couldn't have templates with multiple custom types in 7.x, but you actually can if they are carried over from 6.x! See #72540 for details. I thought this was only possible when using the _default_
mapping, but that is not true. So no need to add special handling for _default_
.
ImmutableOpenMap<String, CompressedXContent> mappings = templateCursor.value.mappings(); | ||
if (mappings != null && mappings.size() == 1) { | ||
String typeName = mappings.iterator().next().key; | ||
if ("_doc".equals(typeName) == false) { |
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.
Tiny comment, this could be MapperService.SINGLE_MAPPING_NAME
.
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.
Oops, I'd meant to go back and find that constant!
This is related to #72540 |
"Multiple mapping types and custom mapping types in index templates and indices are deprecated", | ||
"https://ela.st/es-deprecation-7-multiple-types", | ||
"Update or remove the following index templates before upgrading to 8.0: " | ||
+ templatesWithMultipleTypes |
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.
Should this be allBadTemplates
instead?
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.
Good catch. I'll fix that.
This commit adds a deprecation info API check for custom types in mappings in legacy templates.