Skip to content

[7.x] Disallow merging existing mapping field definitions in templates (#57701)#57822

Merged
dakrone merged 2 commits intoelastic:7.xfrom
dakrone:backport/7.x/pr-57701
Jun 8, 2020
Merged

[7.x] Disallow merging existing mapping field definitions in templates (#57701)#57822
dakrone merged 2 commits intoelastic:7.xfrom
dakrone:backport/7.x/pr-57701

Conversation

@dakrone
Copy link
Copy Markdown
Member

@dakrone dakrone commented Jun 8, 2020

Backports the following commits to 7.x:

…stic#57701)

* Disallow merging existing mapping field definitions in templates

This commit changes the merge strategy introduced in elastic#55607 and elastic#55982. Instead of overwriting these
fields, we now prevent them from being merged with an exception when a user attempts to
overwrite a field.

As part of this, a more robust validation has been added. The existing validation checked whether
templates (composable and component) were valid on their own, this new validation now checks that
the composite template (mappings/settings/aliases) is valid. This means that when a composable
template is added or updated, we confirm that it is valid with its component pieces. When a
component template is updated we ensure that all composable templates that make use of the component
template continue to be valid before allowing the component template to be updated.

This change also necessitated changes in the tests, however, I have left tests that exercise mapping
merging with nested object fields as `@AwaitsFix`, as we intend to change the behavior soon to allow
merging in a recursive-with-replacement fashion (see: elastic#57393). I have added tests that check the new
disallowing behavior in the meantime.

* Use functional instead of imperative prefix collection

* Use IndexService.withTempIndexService

* Rename tests

* Fix tests

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@dakrone dakrone added backport :Data Management/Indices APIs DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead. v7.9.0 labels Jun 8, 2020
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Indices APIs)

@elasticmachine elasticmachine added the Team:Data Management (obsolete) DO NOT USE. This team no longer exists. label Jun 8, 2020
@dakrone dakrone merged commit 6e8cf09 into elastic:7.x Jun 8, 2020
@dakrone dakrone deleted the backport/7.x/pr-57701 branch June 8, 2020 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport :Data Management/Indices APIs DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead. Team:Data Management (obsolete) DO NOT USE. This team no longer exists. v7.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants