From 433d4f21c39fa7c364e3275443f673360dda5d18 Mon Sep 17 00:00:00 2001 From: Julia Bardi <90178898+juliaElastic@users.noreply.github.com> Date: Tue, 22 Aug 2023 18:55:17 +0200 Subject: [PATCH] [Fleet] Fix index patterns being recreated in default space, fix migration version setting (#164456) ## Summary Closes https://github.com/elastic/kibana/issues/164243 Added a `typeMigrationVersion: '8.0.0'` to index patterns until https://github.com/elastic/kibana/issues/164454 is fixed. Related to https://github.com/elastic/kibana/pull/161969 Feedback from kibana core team, we should always set the migration version fields, even if `migrationVersion` is not set. It would be good to backport this to 8.9 too. How to test locally: - create a test space - install system integration in test space - restart kibana - verify that the index patterns `logs-*`, `metrics-*` are still in test space in Data Views UI ### Checklist - [ ] [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 --- .../server/services/epm/kibana/assets/install.ts | 13 ++++++------- .../services/epm/kibana/index_pattern/install.ts | 2 ++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/fleet/server/services/epm/kibana/assets/install.ts b/x-pack/plugins/fleet/server/services/epm/kibana/assets/install.ts index ec0cbab539bcd..fdeb75480ea79 100644 --- a/x-pack/plugins/fleet/server/services/epm/kibana/assets/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/kibana/assets/install.ts @@ -101,13 +101,12 @@ export function createSavedObjectKibanaAsset(asset: ArchiveAsset): SavedObjectTo if (asset.migrationVersion) { so.migrationVersion = asset.migrationVersion; - } else { - if (asset.coreMigrationVersion) { - so.coreMigrationVersion = asset.coreMigrationVersion; - } - if (asset.typeMigrationVersion) { - so.typeMigrationVersion = asset.typeMigrationVersion; - } + } + if (asset.coreMigrationVersion) { + so.coreMigrationVersion = asset.coreMigrationVersion; + } + if (asset.typeMigrationVersion) { + so.typeMigrationVersion = asset.typeMigrationVersion; } return so as SavedObjectToBe; } diff --git a/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.ts b/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.ts index 1637bf19d8df4..91e603e80aee2 100644 --- a/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/kibana/index_pattern/install.ts @@ -18,6 +18,8 @@ export function getIndexPatternSavedObjects() { return indexPatternTypes.map((indexPatternType) => ({ id: `${indexPatternType}-*`, type: INDEX_PATTERN_SAVED_OBJECT_TYPE, + // workaround until https://github.com/elastic/kibana/issues/164454 is fixed + typeMigrationVersion: '8.0.0', attributes: { title: `${indexPatternType}-*`, timeFieldName: '@timestamp',