[Controls] Register controls in a separate persistable state service#209174
[Controls] Register controls in a separate persistable state service#209174nickpeihl wants to merge 6 commits intoelastic:mainfrom
Conversation
… src/core/server/integration_tests/ci_checks'
|
Pinging @elastic/kibana-presentation (Team:Presentation) |
| "core-usage-stats": "b3c04da317c957741ebcdedfea4524049fdc79ff", | ||
| "csp-rule-template": "c151324d5f85178169395eecb12bac6b96064654", | ||
| "dashboard": "211e9ca30f5a95d5f3c27b1bf2b58e6cfa0c9ae9", | ||
| "dashboard": "c4935ad4c077760a0c4bf5663e1b688114a4a248", |
There was a problem hiding this comment.
I'm guessing the registered type for these SOs changed bc they store controls, but I'm having a hard time figuring out what about them changed... Would you mind helping me out 😄 ?
There was a problem hiding this comment.
The hashes created here for the Dashboard and Canvas saved objects include migrations. Previously, controls registered their migrations on the embeddable persistable state service. With this PR, controls is no longer registering migrations on on the embeddable service, but on its own persistable state service.
So Dashboards and Canvas both run embeddable migrations registered on the embeddable service. But controls can never exist on Canvas workpads. So the controls migrations would never change anything on the Canvas saved objects.
However, I missed including these migrations on the Dashboard saved object migrations. This has been remedied in fc21824.
I added some diffs below that show the hashFeed from src/core/packages/test-helpers/so-type-serializer/src/get_migration_hash.ts before they are encoded to hex. You can see that 8.7.0controls migration is removed from the migrationVersions in the Canvas saved objects. But these migrations are no-ops since controls never existed in Canvas.
- canvas-element-multiple-isolated-none-false-8.0.0-7.13.1,7.14.0,7.15.0,7.16.0,7.17.0,8.0.0,8.0.1,8.1.0,8.2.0,8.3.0,8.4.0,8.5.0,8.6.0,8.7.0,8.9.0--{"dynamic":false,"properties.@created.type":"date","properties.@timestamp.type":"date","properties.content.type":"text","properties.help.type":"text","properties.image.type":"text","properties.name.fields.keyword.type":"keyword","properties.name.type":"text"}-8.10.0-
+ canvas-element-multiple-isolated-none-false-8.0.0-7.13.1,7.14.0,7.15.0,7.16.0,7.17.0,8.0.0,8.0.1,8.1.0,8.2.0,8.3.0,8.4.0,8.5.0,8.6.0,8.9.0--{"dynamic":false,"properties.@created.type":"date","properties.@timestamp.type":"date","properties.content.type":"text","properties.help.type":"text","properties.image.type":"text","properties.name.fields.keyword.type":"keyword","properties.name.type":"text"}-8.10.0-
- canvas-workpad-multiple-isolated-none-false-8.0.0-7.0.0,7.13.1,7.14.0,7.15.0,7.16.0,7.17.0,8.0.0,8.0.1,8.1.0,8.2.0,8.3.0,8.4.0,8.5.0,8.6.0,8.7.0,8.9.0--{"dynamic":false,"properties.@created.type":"date","properties.@timestamp.type":"date","properties.name.fields.keyword.type":"keyword","properties.name.type":"text"}-8.10.0-
+ canvas-workpad-multiple-isolated-none-false-8.0.0-7.0.0,7.13.1,7.14.0,7.15.0,7.16.0,7.17.0,8.0.0,8.0.1,8.1.0,8.2.0,8.3.0,8.4.0,8.5.0,8.6.0,8.9.0--{"dynamic":false,"properties.@created.type":"date","properties.@timestamp.type":"date","properties.name.fields.keyword.type":"keyword","properties.name.type":"text"}-8.10.0-
- canvas-workpad-template-agnostic-none-false-none-7.13.1,7.14.0,7.15.0,7.16.0,7.17.0,8.0.0,8.0.1,8.1.0,8.2.0,8.3.0,8.4.0,8.5.0,8.6.0,8.7.0,8.9.0--{"dynamic":false,"properties.help.fields.keyword.type":"keyword","properties.help.type":"text","properties.name.fields.keyword.type":"keyword","properties.name.type":"text","properties.tags.fields.keyword.type":"keyword","properties.tags.type":"text","properties.template_key.type":"keyword"}-8.10.0-
+ canvas-workpad-template-agnostic-none-false-none-7.13.1,7.14.0,7.15.0,7.16.0,7.17.0,8.0.0,8.0.1,8.1.0,8.2.0,8.3.0,8.4.0,8.5.0,8.6.0,8.9.0--{"dynamic":false,"properties.help.fields.keyword.type":"keyword","properties.help.type":"text","properties.name.fields.keyword.type":"keyword","properties.name.type":"text","properties.tags.fields.keyword.type":"keyword","properties.tags.type":"text","properties.template_key.type":"keyword"}-8.10.0-There was a problem hiding this comment.
Ohh I see, thanks for the explanation. I don't have a lot of context on the history of controls and canvas, but that makes sense.
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Unknown metric groupsAPI count
References to deprecated APIs
History
|
jloleysens
left a comment
There was a problem hiding this comment.
Based on what I understand there is no real change to migrations except for canvas which is a noop since the controls migrations would never have run or been used.
Generally I find it a bit scary to remove migrations (even if we believe they are noops) so, my 2c, having some E2E tests in place would make me feel more at ease.
|
|
||
| const controlsMigrations = deps.controls.getAllMigrations(); | ||
|
|
||
| const dependencyMigrations = mergeMigrationFunctionMaps(embeddableMigrations, controlsMigrations); |
There was a problem hiding this comment.
So if I'm following correctly: this refactor is split controlsMigrations from embeddableMigrations and so the end result for dashboards is the same...
ThomThomson
left a comment
There was a problem hiding this comment.
Great to see this separated out, especially because it also mirrors some of the changes we've made clientside where Controls are no longer in the same Embeddable registry.
Looked through the code and everything looks great. Also ran locally, imported the controls migration smoke test (with the workaround to #211113 in place, and ensured that the Controls migrations run properly.
gsoldevila
left a comment
There was a problem hiding this comment.
I think we should define a new modelVersion with an unsafe_transform function instead.
Otherwise, this function will not run for customers that migrate from a version newer than the ones defined in the newly added "migrations", as the data will be considered up-to-date.
There might be a safer and easier method where we use Dashboard's Content Management system to transform at run time the |
|
I think a runtime transformation in Content Management sounds like a safe way to solve this. @gsoldevila, is this something that is acceptable to core? Additionally, this PR isn't introducing any new migrations or transforms - would you mind updating your review? |
| "canvas-workpad-template": "c077b0087346776bb3542b51e1385d172cb24179", | ||
| "canvas-element": "5cea187f4d74520e3da36b18e465e91d344fad3e", | ||
| "canvas-workpad": "b38728356a6ee25d560f519671735fdbadf4604a", | ||
| "canvas-workpad-template": "e32ebe04845a65e33fd441c3d0ab47053c2e3016", |
There was a problem hiding this comment.
I don't understand why these old types have been updated here 🤔 .
|
Ca you hold off merging until #214265 is resolved. That way, we can avoid merge conflicts with backporting as much as possible |
Summary
Register controls in a new ControlsPersistableStateService.
The embeddable persistable state service registry may soon add validation schemas. These schemas will be provided for the Dashboards HTTP API OpenAPI Spec. Since controls are not panels (yet), we want to maintain a separate registry for controls to register schemas so they can be documented in the correct place in the specification.
At this time, this change should have no effect on the UI. This should only affect telemetry collection for controls. In the future, we will use the extract/inject methods on the ControlsPersistableStateService on the Dashboard server so controls will not need to inject and extract references in the UI. More info in #206654.
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:breakinglabel should be applied in these situations.release_note:*label is applied per the guidelinesIdentify risks
Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.
Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.