Skip to content

[8.12] [Dashboard] Only cache non-alias dashboards (#175635)#175706

Merged
kibanamachine merged 1 commit intoelastic:8.12from
kibanamachine:backport/8.12/pr-175635
Jan 26, 2024
Merged

[8.12] [Dashboard] Only cache non-alias dashboards (#175635)#175706
kibanamachine merged 1 commit intoelastic:8.12from
kibanamachine:backport/8.12/pr-175635

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 8.12:

Questions ?

Please refer to the Backport tool documentation

@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Jan 26, 2024
@kibanamachine kibanamachine enabled auto-merge (squash) January 26, 2024 16:15
## Summary

This PR fixes the alias redirect problem that was noted in the attached
SDH.

For context, as part of the [Links panel
work](elastic#166896), I added [dashboard
caching](elastic#162285) to make
navigation more efficient - however, when implementing this, I did not
consider the redirect behaviour.

Specifically, we were **always** adding dashboards to the cache, even if
the load outcome meant a redirect was necessary - so, because the meta
info for the dashboard fetch result was cached, this meant that the
`'aliasMatch'` outcome was **also** cached. Because of this, after a
redirect happened, the second attempt to load the dashboard would return
the result from the **cache** rather than fetching the dashboard from
the CM client - but, as described previously, the cached dashboard would
still appear as though it required a redirect because the cached outcome
was `'aliasMatch'`.

Therefore, because of hitting this early return on **both** fetch
attempts (before the redirect, after the redirect)...

https://github.com/elastic/kibana/blob/4565b1bfba91cd24f73f8ce37fa7be73283a4453/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts#L165-L171

... the dashboard information would not get updated. _(Oof!)_

Despite the lengthy description of the problem, the solution is quite
simple - just don't add dashboards to the cache if they require a
redirect. And then everything works! 🎉

### Videos
**Before**

https://github.com/elastic/kibana/assets/8698078/983b81a6-acf3-4e71-804a-6ed75c36896f

**After**

https://github.com/elastic/kibana/assets/8698078/028369ff-f73f-43e6-9abb-b35f0d2f33e1

### Testing
To test, I followed the directions from [this PR
description](elastic#163658) to get a
dashboard that requires a redirect - then, I created a markdown panel
with the **old** (from the Default space) dashboard ID in the new space
to see the same redirect behaviour that the customer in the SDH was
seeing.

### Checklist
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
- [x] [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

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

(cherry picked from commit 27b34d5)
@kibanamachine kibanamachine force-pushed the backport/8.12/pr-175635 branch from 90735d0 to 42354e9 Compare January 26, 2024 16:19
@kibana-ci
Copy link
Copy Markdown

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dashboard 377.3KB 377.4KB +37.0B

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @Heenawter

@kibanamachine kibanamachine merged commit 5ebb15e into elastic:8.12 Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants