From 5fa9cb561d85e74bce8e0c2645a8e2a3f8e40753 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Fri, 18 Jun 2021 13:45:10 -0700 Subject: [PATCH] [Build] use saved config from valid kbn version (#485) OpenSearch Dashboards supports restart upgrades from Kibana 6.8.0 through Kibana 7.10.2 and to OpenSearch Dashboards 1.0. Noting that the semantic version of the application went from high to low. The application would check if the config saved had a version less than or equal to the current version. If not then it would skip migrating the settings to the current version. This updates enables to migrate settings from Kibana 6.8.0 through 7.10.2 if and only if the current version of OpenSearch Dashboards is 1.0.0. Issues partially resolved: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/334 Signed-off-by: Kawika Avilla --- .../is_config_version_upgradeable.test.ts | 26 +++++++++++++++++++ .../is_config_version_upgradeable.ts | 7 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/core/server/ui_settings/create_or_upgrade_saved_config/is_config_version_upgradeable.test.ts b/src/core/server/ui_settings/create_or_upgrade_saved_config/is_config_version_upgradeable.test.ts index 23c78eaa935c..d694c0ad0bf6 100644 --- a/src/core/server/ui_settings/create_or_upgrade_saved_config/is_config_version_upgradeable.test.ts +++ b/src/core/server/ui_settings/create_or_upgrade_saved_config/is_config_version_upgradeable.test.ts @@ -63,4 +63,30 @@ describe('savedObjects/health_check/isConfigVersionUpgradeable', function () { isUpgradeableTest('50.0.10-rc150-SNAPSHOT', '50.0.9', false); isUpgradeableTest(undefined as any, '7.4.0', false); isUpgradeableTest('@@version', '7.4.0', false); + isUpgradeableTest('6.8.0', '1.0.0', true); + isUpgradeableTest('7.0.0', '1.0.0', true); + isUpgradeableTest('7.10.2', '1.0.0', true); + isUpgradeableTest('6.8.0-rc1', '1.0.0', true); + isUpgradeableTest('7.0.0-rc1', '1.0.0', true); + isUpgradeableTest('7.10.2-rc1', '1.0.0', true); + isUpgradeableTest('6.8.0', '1.0.0-rc1', true); + isUpgradeableTest('7.0.0', '1.0.0-rc1', true); + isUpgradeableTest('7.10.2', '1.0.0-rc1', true); + isUpgradeableTest('6.7.10', '1.0.0', false); + isUpgradeableTest('7.10.3', '1.0.0', false); + isUpgradeableTest('6.7.10-rc1', '1.0.0', false); + isUpgradeableTest('7.10.3-rc1', '1.0.0', false); + isUpgradeableTest('6.7.10', '1.0.0-rc1', false); + isUpgradeableTest('7.10.3', '1.0.0-rc1', false); + isUpgradeableTest('6.8.0', '1.0.1', false); + isUpgradeableTest('7.0.0', '1.0.1', false); + isUpgradeableTest('7.10.2', '1.0.1', false); + isUpgradeableTest('6.8.0-rc1', '1.0.1', false); + isUpgradeableTest('7.0.0-rc1', '1.0.1', false); + isUpgradeableTest('7.10.2-rc1', '1.0.1', false); + isUpgradeableTest('6.8.0', '1.0.1-rc1', false); + isUpgradeableTest('7.0.0', '1.0.1-rc1', false); + isUpgradeableTest('7.10.2', '1.0.1-rc1', false); + isUpgradeableTest('1.0.0-rc1', '1.0.0', true); + isUpgradeableTest('1.0.1', '1.0.0', false); }); diff --git a/src/core/server/ui_settings/create_or_upgrade_saved_config/is_config_version_upgradeable.ts b/src/core/server/ui_settings/create_or_upgrade_saved_config/is_config_version_upgradeable.ts index c5747d490385..d2908cf6939b 100644 --- a/src/core/server/ui_settings/create_or_upgrade_saved_config/is_config_version_upgradeable.ts +++ b/src/core/server/ui_settings/create_or_upgrade_saved_config/is_config_version_upgradeable.ts @@ -72,8 +72,13 @@ export function isConfigVersionUpgradeable( opensearchDashboardsReleaseVersion ); const savedRcIsLessThanOpenSearchDashboards = savedRcNumber < opensearchDashboardsRcNumber; + // If the saved config is from the fork and from 6.8.0 to 7.10.2 then we should be able to upgrade. + const savedIsFromPrefork = + semver.gte(savedReleaseVersion, '6.8.0') && semver.lte(savedReleaseVersion, '7.10.2'); + const currentVersionIsVersion1 = semver.eq(opensearchDashboardsReleaseVersion, '1.0.0'); return ( savedIsLessThanOpenSearchDashboards || - (savedIsSameAsOpenSearchDashboards && savedRcIsLessThanOpenSearchDashboards) + (savedIsSameAsOpenSearchDashboards && savedRcIsLessThanOpenSearchDashboards) || + (savedIsFromPrefork && currentVersionIsVersion1) ); }