Skip to content

Commit b6922a4

Browse files
authored
[Upgrade Assistant] Show more details when systems indices migration fails (#211429)
1 parent 9411829 commit b6922a4

10 files changed

Lines changed: 229 additions & 66 deletions

File tree

x-pack/platform/plugins/private/translations/translations/fr-FR.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48324,7 +48324,6 @@
4832448324
"xpack.upgradeAssistant.overview.systemIndices.loadingError": "Impossible de récupérer le statut des index système",
4832548325
"xpack.upgradeAssistant.overview.systemIndices.migratingLabel": "Migration en cours",
4832648326
"xpack.upgradeAssistant.overview.systemIndices.migrationCompleteLabel": "Migration terminée",
48327-
"xpack.upgradeAssistant.overview.systemIndices.migrationFailedBody": "Une erreur s'est produite lors de la migration des index système pour {feature} : {failureCause}",
4832848327
"xpack.upgradeAssistant.overview.systemIndices.migrationFailedTitle": "Échec de la migration des index système",
4832948328
"xpack.upgradeAssistant.overview.systemIndices.needsMigrationLabel": "Migration requise",
4833048329
"xpack.upgradeAssistant.overview.systemIndices.noMigrationNeeded": "Migration des index système non nécessaire.",

x-pack/platform/plugins/private/translations/translations/ja-JP.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48170,7 +48170,6 @@
4817048170
"xpack.upgradeAssistant.overview.systemIndices.loadingError": "システムインデックスステータスを取得できませんでした",
4817148171
"xpack.upgradeAssistant.overview.systemIndices.migratingLabel": "移行中",
4817248172
"xpack.upgradeAssistant.overview.systemIndices.migrationCompleteLabel": "移行完了",
48173-
"xpack.upgradeAssistant.overview.systemIndices.migrationFailedBody": "{feature}のシステムインデックスの移行中にエラーが発生しました:{failureCause}",
4817448173
"xpack.upgradeAssistant.overview.systemIndices.migrationFailedTitle": "システムインデックスの移行が失敗しました",
4817548174
"xpack.upgradeAssistant.overview.systemIndices.needsMigrationLabel": "移行が必要",
4817648175
"xpack.upgradeAssistant.overview.systemIndices.noMigrationNeeded": "システムインデックスの移行は不要です。",

x-pack/platform/plugins/private/translations/translations/zh-CN.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48277,7 +48277,6 @@
4827748277
"xpack.upgradeAssistant.overview.systemIndices.loadingError": "无法检索系统索引状态",
4827848278
"xpack.upgradeAssistant.overview.systemIndices.migratingLabel": "正在进行迁移",
4827948279
"xpack.upgradeAssistant.overview.systemIndices.migrationCompleteLabel": "迁移完成",
48280-
"xpack.upgradeAssistant.overview.systemIndices.migrationFailedBody": "迁移 {feature} 的系统索引时出错:{failureCause}",
4828148280
"xpack.upgradeAssistant.overview.systemIndices.migrationFailedTitle": "系统索引迁移失败",
4828248281
"xpack.upgradeAssistant.overview.systemIndices.needsMigrationLabel": "需要迁移",
4828348282
"xpack.upgradeAssistant.overview.systemIndices.noMigrationNeeded": "不需要进行系统索引迁移。",

x-pack/platform/plugins/private/upgrade_assistant/__jest__/client_integration/overview/migrate_system_indices/__snapshots__/flyout.test.ts.snap

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/platform/plugins/private/upgrade_assistant/__jest__/client_integration/overview/migrate_system_indices/flyout.test.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { act } from 'react-dom/test-utils';
99

1010
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers';
1111
import { setupEnvironment } from '../../helpers';
12-
import { systemIndicesMigrationStatus } from './mocks';
12+
import { systemIndicesMigrationStatus, systemIndicesMigrationErrorStatus } from './mocks';
1313

1414
describe('Overview - Migrate system indices - Flyout', () => {
1515
let testBed: OverviewTestBed;
@@ -39,4 +39,36 @@ describe('Overview - Migrate system indices - Flyout', () => {
3939
expect(tableCellsValues.length).toBe(systemIndicesMigrationStatus.features.length);
4040
expect(tableCellsValues).toMatchSnapshot();
4141
});
42+
43+
test('shows migration errors inline within the table row', async () => {
44+
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus(systemIndicesMigrationErrorStatus);
45+
46+
await act(async () => {
47+
testBed = await setupOverviewPage(httpSetup);
48+
});
49+
50+
const { component, actions, table } = testBed;
51+
52+
component.update();
53+
54+
await actions.clickViewSystemIndicesState();
55+
56+
const { rows } = table.getMetaData('flyoutDetails');
57+
58+
expect(rows[0].columns[1].value).toBe('Migration failed');
59+
60+
await act(async () => {
61+
rows[0].reactWrapper.find('button').simulate('click');
62+
});
63+
64+
component.update();
65+
66+
const { rows: resultRows } = table.getMetaData('flyoutDetails');
67+
68+
// Should contain two errors about the migration
69+
// We expect results to be on the second row, given that the first row is used as an expander
70+
// and the second holds the collapsible content
71+
expect(resultRows[1].reactWrapper.text()).toContain('.kibanamapper_parsing_exception');
72+
expect(resultRows[1].reactWrapper.text()).toContain('.logsmapper_parsing_exception');
73+
});
4274
});

x-pack/platform/plugins/private/upgrade_assistant/__jest__/client_integration/overview/migrate_system_indices/migrate_system_indices.test.tsx

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { act } from 'react-dom/test-utils';
99

1010
import { setupEnvironment } from '../../helpers';
1111
import { OverviewTestBed, setupOverviewPage } from '../overview.helpers';
12+
import { systemIndicesMigrationErrorStatus } from './mocks';
1213

1314
describe('Overview - Migrate system indices', () => {
1415
let testBed: OverviewTestBed;
@@ -175,33 +176,23 @@ describe('Overview - Migrate system indices', () => {
175176
expect(find('startSystemIndicesMigrationButton').props().disabled).toBe(false);
176177
});
177178

178-
test('Handles errors from migration', async () => {
179-
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus({
180-
migration_status: 'ERROR',
181-
features: [
182-
{
183-
feature_name: 'kibana',
184-
indices: [
185-
{
186-
index: '.kibana',
187-
migration_status: 'ERROR',
188-
failure_cause: {
189-
error: {
190-
type: 'mapper_parsing_exception',
191-
},
192-
},
193-
},
194-
],
195-
},
196-
],
197-
});
179+
test('Shows migration error with details', async () => {
180+
httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus(
181+
systemIndicesMigrationErrorStatus
182+
);
198183

199184
testBed = await setupOverviewPage(httpSetup);
200185

201-
const { exists } = testBed;
186+
const { component, exists, find } = testBed;
187+
188+
component.update();
202189

203190
// Error is displayed
204191
expect(exists('migrationFailedCallout')).toBe(true);
192+
expect(find('migrationFailedCallout').text()).toContain(
193+
'Errors occurred while migrating system indices:kibana: mapper_parsing_exception'
194+
);
195+
205196
// CTA is enabled
206197
expect(exists('startSystemIndicesMigrationButton')).toBe(true);
207198
});

x-pack/platform/plugins/private/upgrade_assistant/__jest__/client_integration/overview/migrate_system_indices/mocks.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,36 @@ export const systemIndicesMigrationStatus: SystemIndicesMigrationStatus = {
5656
},
5757
],
5858
};
59+
60+
export const systemIndicesMigrationErrorStatus: SystemIndicesMigrationStatus = {
61+
migration_status: 'ERROR',
62+
features: [
63+
{
64+
feature_name: 'kibana',
65+
minimum_index_version: '7.1.1',
66+
migration_status: 'ERROR',
67+
indices: [
68+
{
69+
index: '.kibana',
70+
migration_status: 'ERROR',
71+
failure_cause: {
72+
error: {
73+
type: 'mapper_parsing_exception',
74+
reason: 'something failed',
75+
},
76+
},
77+
},
78+
{
79+
index: '.logs',
80+
migration_status: 'ERROR',
81+
failure_cause: {
82+
error: {
83+
type: 'mapper_parsing_exception',
84+
reason: 'something failed',
85+
},
86+
},
87+
},
88+
],
89+
},
90+
],
91+
};

x-pack/platform/plugins/private/upgrade_assistant/common/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ export interface SystemIndicesMigrationFeature {
310310
migration_status: MIGRATION_STATUS;
311311
indices: Array<{
312312
index: string;
313-
version: string;
313+
version?: string;
314+
migration_status?: MIGRATION_STATUS;
314315
failure_cause?: {
315316
error: {
316317
type: string;

x-pack/platform/plugins/private/upgrade_assistant/public/application/components/overview/migrate_system_indices/flyout.tsx

Lines changed: 89 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
* 2.0.
66
*/
77

8-
import React from 'react';
8+
import React, { useState, ReactNode } from 'react';
99
import { startCase } from 'lodash';
10+
import { FormattedMessage } from '@kbn/i18n-react';
1011
import { i18n } from '@kbn/i18n';
11-
1212
import {
1313
EuiButtonEmpty,
1414
EuiFlexGroup,
@@ -22,6 +22,10 @@ import {
2222
EuiIcon,
2323
EuiSpacer,
2424
EuiInMemoryTable,
25+
EuiButtonIcon,
26+
EuiDescriptionList,
27+
EuiScreenReaderOnly,
28+
EuiBasicTableColumn,
2529
} from '@elastic/eui';
2630

2731
import {
@@ -82,6 +86,27 @@ const i18nTexts = {
8286
defaultMessage: 'Status',
8387
}
8488
),
89+
errorTooltipLabel: i18n.translate(
90+
'xpack.upgradeAssistant.overview.systemIndices.errorTooltipLabel',
91+
{
92+
defaultMessage: 'Migration failed for the following indices: ',
93+
}
94+
),
95+
unknownErrorLabel: i18n.translate(
96+
'xpack.upgradeAssistant.overview.systemIndices.unknownErrorLabel',
97+
{
98+
defaultMessage: 'Unknown error',
99+
}
100+
),
101+
};
102+
103+
const getFailedIndices = (feature: SystemIndicesMigrationFeature) => {
104+
return feature.indices
105+
.filter((index) => index.failure_cause && index.failure_cause.error)
106+
.map((index) => ({
107+
index: index.index,
108+
reason: index?.failure_cause?.error.type,
109+
}));
85110
};
86111

87112
const renderMigrationStatus = (status: MIGRATION_STATUS) => {
@@ -138,26 +163,70 @@ const renderMigrationStatus = (status: MIGRATION_STATUS) => {
138163
);
139164
}
140165

141-
return '';
166+
return null;
142167
};
143168

144-
const columns = [
145-
{
146-
field: 'feature_name',
147-
name: i18nTexts.featureNameTableColumn,
148-
sortable: true,
149-
truncateText: true,
150-
render: (name: string) => startCase(name),
151-
},
152-
{
153-
field: 'migration_status',
154-
name: i18nTexts.statusTableColumn,
155-
sortable: true,
156-
render: renderMigrationStatus,
157-
},
158-
];
159-
160169
export const SystemIndicesFlyout = ({ closeFlyout, data }: SystemIndicesFlyoutProps) => {
170+
const [expandedRows, setExpandedRows] = useState<Record<string, ReactNode>>({});
171+
172+
const toggleRow = (feature: SystemIndicesMigrationFeature) => {
173+
setExpandedRows((prev) => {
174+
const newRows = { ...prev };
175+
if (newRows[feature.feature_name]) {
176+
delete newRows[feature.feature_name];
177+
} else {
178+
const failedIndices = getFailedIndices(feature);
179+
const errorDetails = failedIndices.map(({ index, reason }) => ({
180+
title: index,
181+
description: reason || i18nTexts.unknownErrorLabel,
182+
}));
183+
184+
newRows[feature.feature_name] = <EuiDescriptionList listItems={errorDetails} />;
185+
}
186+
return newRows;
187+
});
188+
};
189+
190+
const columns = [
191+
{
192+
field: 'feature_name',
193+
name: i18nTexts.featureNameTableColumn,
194+
sortable: true,
195+
truncateText: true,
196+
render: (name: string) => startCase(name),
197+
},
198+
{
199+
field: 'migration_status',
200+
name: i18nTexts.statusTableColumn,
201+
sortable: true,
202+
render: renderMigrationStatus,
203+
},
204+
{
205+
align: 'right',
206+
width: '40px',
207+
isExpander: true,
208+
name: (
209+
<EuiScreenReaderOnly>
210+
<span>
211+
<FormattedMessage
212+
id="xpack.upgradeAssistant.overview.systemIndices.expandRow"
213+
defaultMessage="Expand row"
214+
/>
215+
</span>
216+
</EuiScreenReaderOnly>
217+
),
218+
render: (feature: SystemIndicesMigrationFeature) => {
219+
return feature.migration_status === 'ERROR' ? (
220+
<EuiButtonIcon
221+
onClick={() => toggleRow(feature)}
222+
aria-label={expandedRows[feature.feature_name] ? 'Collapse' : 'Expand'}
223+
iconType={expandedRows[feature.feature_name] ? 'arrowDown' : 'arrowRight'}
224+
/>
225+
) : null;
226+
},
227+
},
228+
] as Array<EuiBasicTableColumn<SystemIndicesMigrationFeature>>;
229+
161230
return (
162231
<>
163232
<EuiFlyoutHeader hasBorder>
@@ -175,6 +244,7 @@ export const SystemIndicesFlyout = ({ closeFlyout, data }: SystemIndicesFlyoutPr
175244
itemId="feature_name"
176245
items={data.features}
177246
columns={columns}
247+
itemIdToExpandedRowMap={expandedRows}
178248
pagination={true}
179249
sorting={true}
180250
/>

0 commit comments

Comments
 (0)