[Dashboard] Index Pattern Observable Error Handling (#106155)

* add error handling to dashboard index pattern observable to prevent issues when embeddables do not load
This commit is contained in:
Devon Thomson 2021-07-21 14:50:02 -03:00 committed by GitHub
parent 5c18edd89e
commit 5411652aff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 4 deletions

View file

@ -8,8 +8,16 @@
import { uniqBy } from 'lodash';
import deepEqual from 'fast-deep-equal';
import { merge, Observable, pipe } from 'rxjs';
import { distinctUntilChanged, switchMap, startWith, filter, mapTo, map } from 'rxjs/operators';
import { merge, Observable, pipe, EMPTY } from 'rxjs';
import {
distinctUntilChanged,
catchError,
switchMap,
startWith,
filter,
mapTo,
map,
} from 'rxjs/operators';
import { DashboardContainer } from '..';
import { isErrorEmbeddable } from '../../services/embeddable';
@ -73,7 +81,16 @@ export const syncDashboardIndexPatterns = ({
map(() => dashboardContainer!.getChildIds()),
distinctUntilChanged(deepEqual),
switchMap((newChildIds: string[]) =>
merge(...newChildIds.map((childId) => dashboardContainer!.getChild(childId).getOutput$()))
merge(
...newChildIds.map((childId) =>
dashboardContainer!
.getChild(childId)
.getOutput$()
// Embeddables often throw errors into their output streams.
// This should not affect dashboard loading
.pipe(catchError(() => EMPTY))
)
)
)
)
)

View file

@ -6,13 +6,16 @@
* Side Public License, v 1.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['dashboard', 'header', 'common']);
const browser = getService('browser');
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const filterBar = getService('filterBar');
const browser = getService('browser');
/**
* Common test suite for testing exception scenarious within dashboard
@ -22,9 +25,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await esArchiver.loadIfNeeded(
'test/functional/fixtures/es_archiver/dashboard/current/kibana'
);
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/dashboard_error_cases.json'
);
await PageObjects.common.navigateToApp('dashboard');
});
it('correctly loads default index pattern on first load with an error embeddable', async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.loadSavedDashboard('Dashboard with Missing Lens Panel');
await PageObjects.header.waitUntilLoadingHasFinished();
await filterBar.addFilter('bytes', 'is', '12345678');
await PageObjects.header.waitUntilLoadingHasFinished();
expect(await filterBar.getFilterCount()).to.be(1);
});
// wrapping into own describe to make sure new tab is cleaned up even if test failed
// see: https://github.com/elastic/kibana/pull/67280#discussion_r430528122
describe('recreate index pattern link works', () => {

View file

@ -0,0 +1,29 @@
{
"attributes": {
"description": "",
"hits": 0,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"
},
"optionsJSON": "{\"useMargins\":true,\"syncColors\":false,\"hidePanelTitles\":false}",
"panelsJSON": "[{\"version\":\"8.0.0\",\"type\":\"lens\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"b8b3e902-6012-4988-9952-0739d3b70759\"},\"panelIndex\":\"b8b3e902-6012-4988-9952-0739d3b70759\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_b8b3e902-6012-4988-9952-0739d3b70759\"}]",
"timeRestore": false,
"title": "Dashboard with Missing Lens Panel",
"version": 1
},
"coreMigrationVersion": "8.0.0",
"id": "642d9430-e892-11eb-9e56-a51982fab3d4",
"migrationVersion": {
"dashboard": "7.14.0"
},
"references": [
{
"id": "6a23ea60-e892-11eb-9e56-a51982fab3d4",
"name": "b8b3e902-6012-4988-9952-0739d3b70759:panel_b8b3e902-6012-4988-9952-0739d3b70759",
"type": "lens"
}
],
"type": "dashboard",
"updated_at": "2021-07-19T17:25:05.571Z",
"version": "WzYzNSwxXQ=="
}