From 3f49db452ab0cdc40c0d01bb24da5f1eea29ea88 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Tue, 7 Sep 2021 08:24:45 +0200 Subject: [PATCH] improve deprecation messages --- .../deprecations/unknown_object_types.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/core/server/saved_objects/deprecations/unknown_object_types.ts b/src/core/server/saved_objects/deprecations/unknown_object_types.ts index d60a8f6e521d1..5bccbace72995 100644 --- a/src/core/server/saved_objects/deprecations/unknown_object_types.ts +++ b/src/core/server/saved_objects/deprecations/unknown_object_types.ts @@ -65,7 +65,7 @@ const getUnknownTypesQuery = (knownTypes: string[]): estypes.QueryDslQueryContai }; }; -const hasUnknownObjectTypes = async ({ +const getUnknownSavedObjects = async ({ typeRegistry, esClient, kibanaConfig, @@ -91,26 +91,37 @@ const hasUnknownObjectTypes = async ({ }); const { hits: unknownDocs } = body.hits; - return unknownDocs.length > 0; + return unknownDocs.map((doc) => ({ id: doc._id, type: doc._source?.type ?? 'unknown' })); }; export const getUnknownTypesDeprecations = async ( options: UnknownTypesDeprecationOptions ): Promise => { const deprecations: DeprecationsDetails[] = []; - if (await hasUnknownObjectTypes(options)) { + const unknownDocs = await getUnknownSavedObjects(options); + if (unknownDocs.length) { deprecations.push({ title: i18n.translate('core.savedObjects.deprecations.unknownTypes.title', { defaultMessage: 'Saved objects with unknown types are present in Kibana system indices', }), message: i18n.translate('core.savedObjects.deprecations.unknownTypes.message', { - defaultMessage: 'Unknown saved object types can be caused by disabled plugins, or ', + defaultMessage: + 'Upgrades will fail for 8.0+ because documents were found for unknown saved object types.' + + `To ensure that upgrades will succeed in the future, either re-enable plugins or delete these documents from the Kibana indices`, }), level: 'critical', requireRestart: false, deprecationType: undefined, // not config nor feature... correctiveActions: { - manualSteps: [], // TODO + manualSteps: [ + i18n.translate('core.savedObjects.deprecations.unknownTypes.manualSteps.1', { + defaultMessage: 'If plugins are disabled, re-enable the, then restart Kibana.', + }), + i18n.translate('core.savedObjects.deprecations.unknownTypes.manualSteps.2', { + defaultMessage: + 'If no plugins are disabled, or if enabling them does not fix the issue, delete the documents.', + }), + ], api: { path: '/internal/saved_objects/deprecations/_delete_unknown_types', method: 'POST',