-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[Embeddable] Clientside migration system #162986
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
[Embeddable] Clientside migration system #162986
Conversation
💚 CLA has been signed |
dcc92cd
to
6936bee
Compare
…nSystem' into embeddable/migrationSystem
…until Dashboard save, fix jest tests.
…in place. Throw error if Embeddable factory registered with migrations but no latest version
@@ -51,190 +51,6 @@ const commonAttributes: DashboardAttributes = { | |||
title: '', | |||
}; | |||
|
|||
describe('legacy extract references', () => { |
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.
All of these tests & the legacy extract references function have been removed because they are no longer used. It is not possible to upgrade to 8.10 without first upgrading to 7.17, and URLs from before 7.3 are unsupported as of 8.7.0 with this PR
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.
What if a user imports 7.3 saved objects from saved object import UI into 8.11 instance? Will these migrations be needed in that case? Or will saved object import fail?
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.
7.3 used JSON exporting which is incompatible with versions over 8.0 which require NDJSON. 7.17 was the latest version that supported JSON, so the user would have to import them to 7.17 first which would run all the required migrations.
…mbeddableconfig and version
@gchaps @amyjtechwriter here is the current copy for the save prompt: ![]() I'm not sure what to say here exactly, but I'd like to get across that we've run some extra code this time because of a Kibana version upgrade, and if you save your dashboard we won't have to run that extra code anymore! |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@gchaps thank you for the suggestion! I've updated the copy to:
@andreadelrio - do you think having a second badge as per the current design is the right way to notify a Dashboard author that an upgrade has happened and saving their Dashboard is a good idea? |
0a94fe9
to
b8eace5
Compare
Pinging @elastic/kibana-presentation (Team:Presentation) |
@ThomThomson I think the second badge would work however I'm not sure users will know that If we wanted to bring even more attention to the recommendation we could add either a EuiBeacon + EuiTourStep on the ![]() ![]() |
Oh! I really like the |
I would keep both. |
/** | ||
* This version key was used to store Kibana version information from versions 7.3.0 -> 8.11.0. | ||
* As of version 8.11.0, the versioning information is now per-embeddable-type and is stored on the | ||
* embeddable's input. (embeddableConfig in this type). |
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 to clarify, this means that version
will no longer be populated for SavedDashboardPanel
and will be undefined for newly created dashboards?
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.
Yes exactly. The version key will no longer exist in the Dashboard panels themselves. It will exist in the input
and only if the Embeddable factory has a latestVersion
defined.
@@ -51,190 +51,6 @@ const commonAttributes: DashboardAttributes = { | |||
title: '', | |||
}; | |||
|
|||
describe('legacy extract references', () => { |
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.
What if a user imports 7.3 saved objects from saved object import UI into 8.11 instance? Will these migrations be needed in that case? Or will saved object import fail?
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.
LGTM
code review, tested in chrome
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.
persistable state changes LGTM
I've had 👀 on behalf of the Core team. The things this PR doesn't cover make sense in terms of priorities and will need to be done at some point. If there are issues, please link back to the initial work here. If not, they need to be created a.s.a.p |
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: |
@TinaHeiligers I've created issues for the followups identified in this PR: |
@andreadelrio I looked into the |
if (panelMigrationRun) anyMigrationRun = true; | ||
panel.explicitInput = newInput as DashboardPanelState['explicitInput']; | ||
} else if (factory.latestVersion) { | ||
// by reference panels are always considered to be of the latest version |
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.
So a by reference panel that needs a migration would not trigger a "Save recommended"? If a user does edit and save the dashboard would we save the migrated by reference panels too?
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.
For the time being, by reference Embeddables should never need a migration via this system. Any embeddables that can be both by reference or by value will need to implement the same migration function in both the SO migrations, and the clientside Embeddable migrations.
So currently, no it won't trigger a "Save recommended", but if the user saves, we will save the latestVersion
key into the Embeddable's input.
A by reference embeddable may need migration from this system when we implement drilldown migrations, but won't until then.
Closes #158677
Closes #161816
Summary
This PR changes the versioning scheme used by Dashboard Panels and by value Embeddables, and introduces a new clientside system that can migrate Embeddable Inputs to their latest versions.
Embeddable Migration System
How are versions stored?
After this PR Embeddable versions and the migrations between are no longer tied to the Kibana version. Instead, each Embeddable type maintains its own versioning information. This is stored as follows:
When do migrations get run?
The migrations get run as part of the
embeddableFactory.create
process. This means that every Embeddable that gets rendered by any application will receive migrations. Persisting an Embeddable in a saved object no longer means worrying about keeping them up to date or writing any migrations. Just save the input as-is, and pass it to an Embeddable Renderer, which will do the rest.On Dashboards... there are some extra steps.
Dashboard Embeddable Migrations
Usually the process of just rendering an Embeddable and having the migrations happen naturally is enough. For Dashboard this is not the case because:
last saved state
to allow for resetting and diff checking. Resetting a Dashboard should not undo migrations!For these reasons, Dashboards run a function clientside on saved object load. This function migrates all panels and Controls on the Dashboard before the Embeddables are even created. If this function detects any changes a save prompt will be shown
Save Prompt
Saving back-propagates any changes from the migrations back to the saved object, and can make loading faster next time because migrations can be skipped. To encourage users to do this if changes have been detected and the Dashboard is in edit mode a prompt will be shown next to the
unsaved changes
badge. Here is the prompt in context:Old Version Key
There is a version key in the Dashboard panel type which has historically stored the Kibana version the Dashboard was last saved on.
In this PR that version key was removed and version information was moved inside the Input key so that all Embeddables can be versioned, not just the ones stored in Dashboards. As part of that change, the two usages of the old version key needed to be updated to reflect that the older version key can be missing.
The two usages were:
gridData
key.How to test
src/plugins/image_embeddable/public/image_embeddable/image_embeddable_factory.tsx
The new
save prompt
should show, but theunsaved changes
badge should not show. Resetting the input, switching back and forth between view & edit mode and any action done on the Dashboard should not undo the migration, or run the migration again on already migrated input.If the migration runs against the input more than once, you'll see the alt text become:
Neat migration! Previous alt text was "Neat migration! Previous alt text was "Whatever your alt text was originally""
.What is not covered?
This PR is a very basic and simple version of the clientside migration system. More functionality and features can be added to it as they are needed. Because of this, some pieces are missing:
Right now, the Dashboard does not run clientside Control Group Migrations. This is because in order to do so, the Dashboard Saved Object would need to optionally store a Control Group version, which would require changes in the saved object schema, and the content management. Before we can implement any migrations for the Control Group itself we will need to make these changes. Fortunately, migrations are quite rare for the Control Group itself.
Drilldown Migrations are not covered at the moment because in order for them to be implemented we would need to extend the Embeddable Enhancements system to be able to store version information independent from the actual Embeddable version. There are currently no migrations registered for drilldowns, but before we add one, we would need to ensure that a system for properly versioning them is in place.
Propagation from child Embeddables back to Container
The function that runs on Dashboard saved object load means that most of the time, when the embeddable create function is called on Dashboards there are no more migrations to be run. If for any reason there are migrations to be run at this point, the embeddable inheritance structure means they get immediately undone because the Container's child input is considered the source of truth. This could happen when:
Implementing this back-propagation on the existing Embeddables framework would require ugly workarounds and changes that would affect the stability of the Embeddable platform. Once we move to a less prescriptive inheritance structure, this will not be a problem.
Checklist
Delete any items that are not applicable to this PR.