-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] Remove legacy component templates on package install #130758
[Fleet] Remove legacy component templates on package install #130758
Conversation
Pinging @elastic/fleet (Team:Fleet) |
@elasticmachine merge upstream |
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.
Just a couple nitpicky code things - didn't pull down the code to test quite yet. Thanks for all the tests here!
x-pack/plugins/fleet/server/services/epm/elasticsearch/template/remove_legacy.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/fleet/server/services/epm/elasticsearch/template/remove_legacy.ts
Show resolved
Hide resolved
x-pack/plugins/fleet/server/services/epm/elasticsearch/template/remove_legacy.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/fleet/server/services/epm/elasticsearch/template/remove_legacy.ts
Outdated
Show resolved
Hide resolved
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.
Tested locally with an upgrade from 8.0 with few packages to that PR and looks like it working fine 🚀
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: cc @hop-dev |
* remove legacy component templates as part of package install * re-work unit tests * remove unnecessary await * check if component templates are in use before deleting * add integration tests * PR feedback Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit dccca6b)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
@hop-dev If this PR doesn't make the 8.2.0 release, will this cleanup logic work if a user upgrades to 8.2.0 first where the templates aren't cleaned up and then later upgrade to 8.2.1? |
…130758) (#130803) * [Fleet] Remove legacy component templates on package install (#130758) * remove legacy component templates as part of package install * re-work unit tests * remove unnecessary await * check if component templates are in use before deleting * add integration tests * PR feedback Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit dccca6b) * fix imports Co-authored-by: Mark Hopkin <mark.hopkin@elastic.co> Co-authored-by: Jen Huang <jen.huang@elastic.co>
Yes, we look for legacy component templates on every package install regardless of stack version. (performance wise, in the case where there aren't any legacy templates, this will just perform a get component templates call and then exit early, so felt acceptable) |
…#130758) * remove legacy component templates as part of package install * re-work unit tests * remove unnecessary await * check if component templates are in use before deleting * add integration tests * PR feedback Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
Closes #129662
Remove any legacy
@mappings
or@settings
component templates during package install. Only delete if:_meta.package.name
matches the package being installed (incase the user has created their own version, or another package had created the component template, not likely but I put the check there just in case)Background
In #121184 we introduced the
@package
component template which is a combination of@mappings
and@settings
.In #129662 @nchaulet noticed that when installing a package in 8.2 which was previously installed in a lower version, we failed to clean up the legacy
@mapping
component templatesWhen
When installing a package, check to see if there are any legacy templates
Testing
I've added unit and functional tests.
Manual test steps:
Expand for Kibana Dev Tools Commands for Manual Testing
Scenario 1 - component templates not used by index templates
Scenario 2 - component templates are used by an index template