-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Changes in package install format should be applied on Stack upgrades #121099
Comments
Pinging @elastic/fleet (Team:Fleet) |
One concern with implementing this change is the performance issues we've encountered writing templates and pipelines in bulk to Elasticsearch. See #110500 for my initial investigations into this. We could either workaround this issue by having some UI state that blocks users from upgrading or removing packages that are in this migrating state or work with Elasticsearch on elastic/elasticsearch#77505 so that we could include these migrations in our normal Fleet setup flow which will soon block Kibana startup. |
@elastic/fleet I've completed a first draft of the design options above along with my recommendation. Would love to get feedback on this in the next week or so. |
I've updated the issue with the summarized implementation plan based on the live discussion we had last week. This is now ready for implementation. |
The term "reinstall" is used several times. The way I understand reinstall is that all assets (including policy integrations instances) are wiped and the package is installed again. I doubt this is the case as otherwise lots of policies would fall apart. I assume all assets except policies are added again (are assets removed before added again?). Maybe we should refer to it as refresh or something similar? My main concern around reinstall is how often we rollover data streams. Ideally we should never have to rollover data streams for these changes but just update mappings and settings. I'm aware this is not always possible. But with Fleet become more mature I also expect the number of these changes is actually going down. A more general note, we should have docs on what we consider just "internals" of Fleet and are not breaking change and what are. For example a change on the content of |
Whenever Fleet makes changes to how package assets are installed into Elasticsearch or Kibana, the changes are not applied to packages that were installed on prior versions of Kibana, until the package is upgraded. This can cause a discrepancy in what we can document and instruct users to do, based on what Stack version they were running when they installed a package instead of which Stack version they are running now.
A simple example would be a case where we add a new field to the
_meta
object applied to all Elasticsearch assets (index templates, ingest pipelines, etc.)Examples of recent changes that are affected by this issue:
_meta
on Elasticsearch assets #111737Future planned changes that will be affected:
Ideally, when the Stack is upgraded, all package assets are installed in a consistent format, regardless of whether or not the package was originally installed before or after the Stack upgrade.
Today, users can work around this limitation by forcing a package to be reinstalled via the API:
Design
This section summarizes the design that was chosen based on discussion in the Fleet team. See the full discussion of implementation options below for more detail about the rationale.
install_format_schema_version
to theepm-packages
objectsINSTALL_FORMAT_SCHEMA_VERSION
constant to the Fleet's implementation code that we manually increment when there's a schema changeepm-packages
objects whereinstall_format_schema_version
is null or <INSTALL_FORMAT_SCHEMA_VERSION
constant in codedata
tarball) to be used for future tests. This snapshot represents the current state to be expected of the current install format schema.create_time
field on transforms)Full design discussion
Types of asset changes that we need to handle
_meta
on Elasticsearch assets #111737High-level options
Given the number of different ways the package install format could change, we either need to:
epm-packages
object and whenever the expected hash doesn't match the last stored hash, we reinstall the package.I believe we should attempt to go with option (1) and first test the performance of this strategy with ~100 packages before attempting any of the strategies under option (2).
Minimizing reinstalls for heavy-handed approach (option 1)
We need to be able to know when a package should be reinstalled to avoid reinstalling all packages on every Kibana boot which could be performance intensive and have other undesirable side-effects like rolling over data streams. Ways to track this:
install_format_schema_version
field toepm-packages
objects and then trigger a reinstall any time the current schema version >install_format_schema_version
installed_by_kibana_version
field to theepm-packages
objects and then trigger a reinstall any time the current Kibana version is >installed_by_kibana_version
.Detecting install format changes automatically
If we later find that the manual strategy of updating an install format schema version in our code is too prone to human error, we should explore detecting changes in the install format automatically, either at dev/test time or in production.
During development
We could attempt to detect these changes automatically before a PR is merged with some automated tests. This could work like:
data
tarball) to be used for future testselastic-package export
?)This would catch scenarios where the install format schema version should have been incremented in code but was not.
We likely would not be able to catch all changes with this strategy since there could be some types of changes that only affect some packages and it'd be impractical to try to test this against all packages. However, it's likely that some margin of error here would be acceptable and the vast majority of changes that require a reinstall should be caught with this strategy.
In production (option 2)
Detecting when the package install format has changed in production would be more complicated, require much more effort, and introduce more uncertainty during the upgrade process. However it could potentially catch more cases where we need to reinstall a package and didn't with the more manual approach outlined above (option 1).
I don't recommend pursuing this option unless we find this to be a persistent problem. As Fleet stabilizes, we don't intend to make ongoing changes to the install format and I suspect the test-based strategy above will find cases that we miss.
@joshdover's recommendation
In summary, I recommend we do the following:
install_format_schema_version
to theepm-packages
objectsINSTALL_FORMAT_SCHEMA_VERSION
constant to the Fleet's implementation code that we manually increment when there's a schema changeNotes
kibana/x-pack/plugins/fleet/server/services/setup.ts
Lines 152 to 179 in 06e41b4
The text was updated successfully, but these errors were encountered: