-
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 upgradePackage
and consolidate it with installPackage
, optimize calls to create index patterns
#94490
[Fleet] Remove upgradePackage
and consolidate it with installPackage
, optimize calls to create index patterns
#94490
Conversation
…rn creation & deletion, instead of interacting directly with index pattern SOs
…r of consolidating with installPackage(), use installPackage() for bulk install instead
…bulk package installation, install index pattern only if one or more packages are actually new installs, add debug logging
This reverts commit b9770fd.
Pinging @elastic/fleet (Team:Fleet) |
@jen-huang I'm skeptical but we can discuss it tomorrow. |
Changes look good to me, good job on the simplification! I'll have to redo some bits from what I'm working on, but if this PR gets in reasonably quickly that's not a problem at all. |
@jen-huang I tested installing the endpoint package using the I noticed that the transform was being reinitialized on each |
… allowNoIndex is true" This reverts commit afc91ce.
indexPatternService
instead of writing directly to SOsupgradePackage
and consolidate it with installPackage
, optimize calls to create index patterns
@elastic/fleet @jonathan-buttner Per discussion with @mattkime and others, we decided to table the changes to |
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Page load bundle
History
To update your PR or re-run it, just comment with: cc @jen-huang |
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 tested this locally and did not manage to break it, so I'd say let's get this in rather sooner than later 🚀
I very much like the simplifications in the package installation parts.
Thanks for testing this @skh, appreciate it! I will merge and backport this now. |
…ge`, optimize calls to create index patterns (elastic#94490) * Add data plugin to server app context * First attempt at switching to indexPatternService for EPM index pattern creation & deletion, instead of interacting directly with index pattern SOs * Simplify bulk install package, remove upgradePackage() method in favor of consolidating with installPackage(), use installPackage() for bulk install instead * Update tests * Change cache logging of objects to trace level * Install index patterns as a post-package installation operation, for bulk package installation, install index pattern only if one or more packages are actually new installs, add debug logging * Allow getAsSavedObjectBody to return non-scripted fields when allowNoIndex is true * Allow `getFieldsForWildcard` to return fields saved on index pattern when allowNoIndices is true * Bring back passing custom ID for index pattern SO * Fix tests * Revert "Merge branch 'index-pattern/allow-no-index' into epm/missing-index-patterns" This reverts commit 8e712e9, reversing changes made to af0fb0e. * Allow getAsSavedObjectBody to return non-scripted fields when allowNoIndex is true (cherry picked from commit 69b93da) * Update API docs * Run post-install ops for install by upload too * Remove allowedInstallTypes param * Adjust force install conditions * Revert "Update API docs" This reverts commit b9770fd. * Revert "Allow getAsSavedObjectBody to return non-scripted fields when allowNoIndex is true" This reverts commit afc91ce. * Go back to using SO client for index patterns :( * Stringify attributes again for SO client saving * Fix condition for reinstall same pkg version * Remove unused type * Adjust comment * Update snapshot Co-authored-by: Kibana Machine <[email protected]>
…ge`, optimize calls to create index patterns (#94490) (#95219) * Add data plugin to server app context * First attempt at switching to indexPatternService for EPM index pattern creation & deletion, instead of interacting directly with index pattern SOs * Simplify bulk install package, remove upgradePackage() method in favor of consolidating with installPackage(), use installPackage() for bulk install instead * Update tests * Change cache logging of objects to trace level * Install index patterns as a post-package installation operation, for bulk package installation, install index pattern only if one or more packages are actually new installs, add debug logging * Allow getAsSavedObjectBody to return non-scripted fields when allowNoIndex is true * Allow `getFieldsForWildcard` to return fields saved on index pattern when allowNoIndices is true * Bring back passing custom ID for index pattern SO * Fix tests * Revert "Merge branch 'index-pattern/allow-no-index' into epm/missing-index-patterns" This reverts commit 8e712e9, reversing changes made to af0fb0e. * Allow getAsSavedObjectBody to return non-scripted fields when allowNoIndex is true (cherry picked from commit 69b93da) * Update API docs * Run post-install ops for install by upload too * Remove allowedInstallTypes param * Adjust force install conditions * Revert "Update API docs" This reverts commit b9770fd. * Revert "Allow getAsSavedObjectBody to return non-scripted fields when allowNoIndex is true" This reverts commit afc91ce. * Go back to using SO client for index patterns :( * Stringify attributes again for SO client saving * Fix condition for reinstall same pkg version * Remove unused type * Adjust comment * Update snapshot Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Jen Huang <[email protected]>
Summary
This PR resolves Fleet plugin's portion of #91715 by removing direct calls to index pattern saved objects inserver/services/epm/kibana/index_pattern/install.ts
and replacing them with calls to data plugin'sIndexPatternService
.Changes were made to data plugin'sIndexPatternService
to allow non-scripted fields to be returned fromgetAsSavedObjectBody
whenallowNoIndex
is true: afc91ce. This allows the call to create and save the index pattern to work correctly.March 17 update:
IndexPatternService
does not work for the way EPM installs index patterns. We decided to pull out the changes I had here to get the service working for EPM in favor of having more discussions about potential solutions first, so unfortunately we still need to write directly to the index pattern saved objects themselves in the meantime 😞IndexPatternService
when that's ready. Plus I think some of the simplifications introduced in this PR are beneficial for our error handling efforts, so I'd like to still get these changes in if the team agrees.This PR introduces the following changes to EPM package installation:
upgradePackage
method, which was only being used bybulkInstallPackages
, sinceinstallPackage
can do the same thing (upgrade a package)bulkInstallPackages
to useinstallPackage
insteadupgradePackage
's use ofhandleInstallPackageFailure
by adding it toinstallPackageFromRegistry
InstallResult
and use in various places where we previously had justAssetReference[]
, this new type will allow us to be more verbose about install results in the future, for now it includes an additionalstatus: 'installed' | 'already_installed'
propertyinstallIndexPatterns
as a skippable post-install operation ininstallPackage
, rather than in_installPackage()
bulkInstallPackages
to skip this operation and runinstallIndexPatterns
after all package installations are done to avoid race conditions that create duplicate index patterns (for example, on plugin setup call where we install multiple default packages, multiplelogs-*
andmetrics-*
patterns were created)The race condition was not an issue before when we were overwriting directly to SO based on IDWe are keeping writing to SOs, but this still reduces the the amount of times we write to themanalyzed
anddoc_value
properties were removed for index pattern fields after offline discussions, they are not used by Kibana, they are preserved for index template fieldstype
will default tostring
for unknown types sinceIndexPatternService
does not support undefinedtype
Even though there are quite a lot of changes here, everything around package installation and index patterns should behave the same way as before. To test this PR, ensure that the index patterns are created properly, with the right fields, whenever packages are installed, ungraded, or removed.