Backfill tabs for Discover Session saved object#228115
Backfill tabs for Discover Session saved object#228115lukasolson merged 19 commits intoelastic:mainfrom
tabs for Discover Session saved object#228115Conversation
… �H �H �H �H �H �H �H �H �H �H �H �H for Discover Session saved object
… src/core/server/integration_tests/ci_checks'
…/kibana into discover_tabs_schema_backfill
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
davismcphee
left a comment
There was a problem hiding this comment.
Code changes look good to me, and it seemed to work well overall when testing.
An existing Discover session created in main was correctly updated with the tabs array when opening it in this PR branch, and a new Discover session created in this branch included the tabs array as expected. Making changes in either case and saving caused the first tabs entry to be synced with the root attributes as expected.
I then switched back to main and was able to open, modify, and save both of the Discover sessions without issues. After doing this and again switching back to the PR branch, the modifications made in main were again synced to the first tabs array entry.
The only thing I noticed that I'm unsure about is the handling of by value Discover session panels in dashboards. I left some more details in a comment below.
There was a problem hiding this comment.
I did some testing with Discover session dashboard panels and noticed this situation:
- Created a dashboard in
mainwith a by reference Discover session panel, then duplicated it which created a separate by value panel. Saved the dashboard with both panels. - Switched to this PR branch and opened the dashboard. Duplicated the existing by value panel, leaving me with one by reference panel and two by value panels. Saved the dashboard again.
- Navigated to saved objects management and inspected the dashboard. The newly duplicated by value panel was updated with a tabs array, but the existing by value panel created in
mainwas not.
So it looks like existing by value panels will not get the tabs array, but new ones will. Does this seem ok for now, or could it cause issues for the followup steps we have planned?
There was a problem hiding this comment.
nit: you should also test export/imports 😇
There was a problem hiding this comment.
In any case: for the by values use case. Is there anything that we can do in Core to help migrate those?
It sounds like we should apply transforms to dashboards whenever an embeddable declares transforms.
Maybe we can work around it by defining a model version bump of type data_backfill that reapplies the same logic that's currently applied when re-saving the dashboard?
There was a problem hiding this comment.
@afharo Good catch and suggestion. Tested again today and ensured import/export works as expected:
- Created a Discover session and a dashboard with a by reference and by value Discover panel in
main. Exported both SOs. - Switched to the PR branch and imported the Discover session and dashboard. Confirmed both imported as expected and were able to be opened without issues. Similar situation as above where the Discover session was updated with a tabs array, but the by value panel wasn't.
- Modified both in the PR branch and re-exported/imported, confirming there were still no issues.
Is there anything that we can do in Core to help migrate those?
Regarding the dashboard migration piece, I'm not really sure tbh. I'm under the impression the way panel maintainers are supposed to support backward compatibility currently is through the client side serialize/deserialize logic since there isn't real support for panel transforms yet. But I think there may be plans for something more complete on the Dashboard side. Maybe someone from @elastic/kibana-presentation can give some guidance?
There was a problem hiding this comment.
embeddable transforms registry merged last week. This allows embeddables to register a function to transform embeddable state as part of dashboard CRUD read request prior to sending dashboard response.
This is part of dashboards as code project to allow embeddables to 1) inject references on read so that responses do not contain references. 2) transform embeddable state on read to provide better formated by-value state. Then on write, the transforms provide a way for embeddables to extract references prior to saving dashboard saved object.
Embeddable transforms can make any state changes so you could add tabs support with transforms.
There was a problem hiding this comment.
Thanks for the info @nreese, great to know. @lukasolson and I chatted about this and we're going to try to use it in this PR to take care of the by value panels.
There was a problem hiding this comment.
Tested these scenarios again and confirmed both are now working as expected: existing by value Discover session panels are now correctly updated with the tabs array on read, and the tabs array is persisted to the dashboard SO on save.
| const { title, description, ...tabAttrs } = attributes; | ||
| const tabs = [ | ||
| { | ||
| id: uuidv4(), |
There was a problem hiding this comment.
I assume at some point we'll ned to stabilize these IDs, but it doesn't really matter for now since we're not actually using the tabs yet?
There was a problem hiding this comment.
Yes, it would definitely be good to stabilize these once we're using them.
…/kibana into discover_tabs_schema_backfill
|
|
||
| plugins.embeddable.registerEmbeddableFactory(createSearchEmbeddableFactory()); | ||
| plugins.embeddable.registerTransforms(SEARCH_EMBEDDABLE_TYPE, { | ||
| transformOut: (state) => { |
There was a problem hiding this comment.
Make sure to register transforms in public as well so that short link URL state gets transformed.
There was a problem hiding this comment.
Thanks for the heads up 👍
davismcphee
left a comment
There was a problem hiding this comment.
Thanks for the updates! Tested again after the latest changes and LGTM 👍 Seems like we just need to make one more minor change to run the same panel transform on the client, and this should be good to go.
|
|
||
| plugins.embeddable.registerEmbeddableFactory(createSearchEmbeddableFactory()); | ||
| plugins.embeddable.registerTransforms(SEARCH_EMBEDDABLE_TYPE, { | ||
| transformOut: (state) => { |
There was a problem hiding this comment.
Thanks for the heads up 👍
There was a problem hiding this comment.
Tested these scenarios again and confirmed both are now working as expected: existing by value Discover session panels are now correctly updated with the tabs array on read, and the tabs array is persisted to the dashboard SO on save.
davismcphee
left a comment
There was a problem hiding this comment.
Code-only review, just a final check with the latest updates, LGTM 👍
| }); | ||
|
|
||
| plugins.embeddable.registerTransforms(SEARCH_EMBEDDABLE_TYPE, async () => { | ||
| const { searchEmbeddableTransforms } = await import('../common/embeddable'); |
There was a problem hiding this comment.
| const { searchEmbeddableTransforms } = await import('../common/embeddable'); | |
| const { searchEmbeddableTransforms } = await getEmbeddableServices(); |
Nit: this could probably be grouped with the embeddable_services bundle to limit async module imports:
|
/ci |
|
/ci |
1 similar comment
|
/ci |
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
History
cc @lukasolson |
ThomThomson
left a comment
There was a problem hiding this comment.
Copied changes from #228511 to make the transforms registry accessible LGTM! Nice work!
## Summary Part of elastic#219268. **Adds `tabs` field + sync code**: Adds a new (optional) `tabs` field. Implements code to sync the fields between the existing top-level attributes and the new `tabs` field. (In other words, the `tabs` array will contain a single item that has the same data that is in the top-level attributes with the exception of `title` and `description`.) Uses a `data_backfill` function to eagerly migrate existing saved objects to populate this field. After this PR is merged, wait for the next serverless release before merging the next steps. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify 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. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Davis McPhee <davis.mcphee@elastic.co> Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
## Summary Part of #219268. Follow-up to #228115. Marks `tabs` as required inside `SavedSearchAttributes`. Moves consumers (content management APIs & embeddables) to use the new `tabs` field and treat the field as required. Preserves the code that syncs these two shapes of data. After this PR is merged, wait for the next serverless release before merging the next step. This is just a temporary step in moving the discover session attributes (such as `grid`, `columns`) from the top level to the `tabs` array. As of this step, we are still duplicating the attributes & syncing them (for backwards compatibility). In a future step we will completely remove them from the top level & only read them from the `tabs` array. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify 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. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
…ic#229897) ## Summary Part of elastic#219268. Follow-up to elastic#228115. Marks `tabs` as required inside `SavedSearchAttributes`. Moves consumers (content management APIs & embeddables) to use the new `tabs` field and treat the field as required. Preserves the code that syncs these two shapes of data. After this PR is merged, wait for the next serverless release before merging the next step. This is just a temporary step in moving the discover session attributes (such as `grid`, `columns`) from the top level to the `tabs` array. As of this step, we are still duplicating the attributes & syncing them (for backwards compatibility). In a future step we will completely remove them from the top level & only read them from the `tabs` array. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify 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. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
…ic#229897) ## Summary Part of elastic#219268. Follow-up to elastic#228115. Marks `tabs` as required inside `SavedSearchAttributes`. Moves consumers (content management APIs & embeddables) to use the new `tabs` field and treat the field as required. Preserves the code that syncs these two shapes of data. After this PR is merged, wait for the next serverless release before merging the next step. This is just a temporary step in moving the discover session attributes (such as `grid`, `columns`) from the top level to the `tabs` array. As of this step, we are still duplicating the attributes & syncing them (for backwards compatibility). In a future step we will completely remove them from the top level & only read them from the `tabs` array. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify 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. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
…ic#229897) ## Summary Part of elastic#219268. Follow-up to elastic#228115. Marks `tabs` as required inside `SavedSearchAttributes`. Moves consumers (content management APIs & embeddables) to use the new `tabs` field and treat the field as required. Preserves the code that syncs these two shapes of data. After this PR is merged, wait for the next serverless release before merging the next step. This is just a temporary step in moving the discover session attributes (such as `grid`, `columns`) from the top level to the `tabs` array. As of this step, we are still duplicating the attributes & syncing them (for backwards compatibility). In a future step we will completely remove them from the top level & only read them from the `tabs` array. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify 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. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>
Summary
Part of #219268.
Adds
tabsfield + sync code: Adds a new (optional)tabsfield. Implements code to sync the fields between the existing top-level attributes and the newtabsfield. (In other words, thetabsarray will contain a single item that has the same data that is in the top-level attributes with the exception oftitleanddescription.) Uses adata_backfillfunction to eagerly migrate existing saved objects to populate this field. After this PR is merged, wait for the next serverless release before merging the next steps.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 guidelinesbackport:*labels.Identify 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.