diff --git a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/migrate_system_indices/migrate_system_indices.test.tsx b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/migrate_system_indices/migrate_system_indices.test.tsx index f6c69c818b378..e3f6d747deaed 100644 --- a/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/migrate_system_indices/migrate_system_indices.test.tsx +++ b/x-pack/plugins/upgrade_assistant/__jest__/client_integration/overview/migrate_system_indices/migrate_system_indices.test.tsx @@ -132,5 +132,36 @@ describe('Overview - Migrate system indices', () => { expect(exists('startSystemIndicesMigrationButton')).toBe(true); expect(find('startSystemIndicesMigrationButton').props().disabled).toBe(false); }); + + test('Handles errors from migration', async () => { + httpRequestsMockHelpers.setLoadSystemIndicesMigrationStatus({ + migration_status: 'ERROR', + features: [ + { + feature_name: 'kibana', + indices: [ + { + index: '.kibana', + migration_status: 'ERROR', + failure_cause: { + error: { + type: 'mapper_parsing_exception', + }, + }, + }, + ], + }, + ], + }); + + testBed = await setupOverviewPage(); + + const { exists } = testBed; + + // Error is displayed + expect(exists('migrationFailedCallout')).toBe(true); + // CTA is enabled + expect(exists('startSystemIndicesMigrationButton')).toBe(true); + }); }); }); diff --git a/x-pack/plugins/upgrade_assistant/common/types.ts b/x-pack/plugins/upgrade_assistant/common/types.ts index 0de19630bcebd..89afa05dfe222 100644 --- a/x-pack/plugins/upgrade_assistant/common/types.ts +++ b/x-pack/plugins/upgrade_assistant/common/types.ts @@ -239,6 +239,12 @@ export interface SystemIndicesMigrationFeature { indices: Array<{ index: string; version: string; + failure_cause?: { + error: { + type: string; + reason: string; + }; + }; }>; } export interface SystemIndicesMigrationStatus { diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/overview/migrate_system_indices/migrate_system_indices.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/overview/migrate_system_indices/migrate_system_indices.tsx index e54568117789a..d14958148b2f8 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/overview/migrate_system_indices/migrate_system_indices.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/overview/migrate_system_indices/migrate_system_indices.tsx @@ -8,6 +8,7 @@ import React, { FunctionComponent, useEffect } from 'react'; import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; import { EuiText, EuiButton, @@ -17,9 +18,11 @@ import { EuiCallOut, EuiFlexGroup, EuiFlexItem, + EuiCode, } from '@elastic/eui'; import type { EuiStepProps } from '@elastic/eui/src/components/steps/step'; +import type { SystemIndicesMigrationFeature } from '../../../../../common/types'; import type { OverviewStepProps } from '../../types'; import { useMigrateSystemIndices } from './use_migrate_system_indices'; @@ -27,6 +30,20 @@ interface Props { setIsComplete: OverviewStepProps['setIsComplete']; } +const getFailureCause = (features: SystemIndicesMigrationFeature[]) => { + const featureWithError = features.find((feature) => feature.migration_status === 'ERROR'); + + if (featureWithError) { + const indexWithError = featureWithError.indices.find((index) => index.failure_cause); + return { + feature: featureWithError?.feature_name, + failureCause: indexWithError?.failure_cause?.error.type, + }; + } + + return {}; +}; + const i18nTexts = { title: i18n.translate('xpack.upgradeAssistant.overview.systemIndices.title', { defaultMessage: 'Migrate system indices', @@ -67,6 +84,26 @@ const i18nTexts = { loadingError: i18n.translate('xpack.upgradeAssistant.overview.systemIndices.loadingError', { defaultMessage: 'Could not retrieve the system indices status', }), + migrationFailedTitle: i18n.translate( + 'xpack.upgradeAssistant.overview.systemIndices.migrationFailedTitle', + { + defaultMessage: 'System indices migration failed', + } + ), + migrationFailedBody: (features: SystemIndicesMigrationFeature[]) => { + const { feature, failureCause } = getFailureCause(features); + + return ( + {failureCause}, + }} + /> + ); + }, }; const MigrateSystemIndicesStep: FunctionComponent = ({ setIsComplete }) => { @@ -137,6 +174,21 @@ const MigrateSystemIndicesStep: FunctionComponent = ({ setIsComplete }) = )} + {migrationStatus.data?.migration_status === 'ERROR' && ( + <> + +

{i18nTexts.migrationFailedBody(migrationStatus.data?.features)}

+
+ + + )} +