From d07e08bb3fb069931b1f39a08bb438cbdf8250f2 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Tue, 31 Aug 2021 15:29:23 -0700 Subject: [PATCH] [1.0][Build] use saved legacy config for 1.x An original update to enable taking settings from a valid legacy version and applying to current OpenSearch Dashboards was made here: https://github.com/opensearch-project/OpenSearch-Dashboards/pull/485 However, it explicitly checked for current version being 1.0.0, which is too strict because ideally all versions of 1.x is compatible. This makes the config check more relaxed and will taking settings from a legacy version if the current version is 1.x. Issue resolved: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/741 Backport PR: https://github.com/opensearch-project/OpenSearch-Dashboards/pull/743 Signed-off-by: Kawika Avilla --- .../is_config_version_upgradeable.test.ts | 20 ++++++++++--------- .../is_config_version_upgradeable.ts | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) 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 d694c0ad0bf6..0f2b9eced0dd 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 @@ -78,15 +78,17 @@ describe('savedObjects/health_check/isConfigVersionUpgradeable', function () { 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('6.8.0', '1.0.1', true); + isUpgradeableTest('7.0.0', '1.0.1', true); + isUpgradeableTest('7.10.2', '1.0.1', true); + isUpgradeableTest('6.8.0-rc1', '1.0.1', true); + isUpgradeableTest('7.0.0-rc1', '1.0.1', true); + isUpgradeableTest('7.10.2-rc1', '1.0.1', true); + isUpgradeableTest('6.8.0', '1.0.1-rc1', true); + isUpgradeableTest('7.0.0', '1.0.1-rc1', true); + isUpgradeableTest('7.10.2', '1.0.1-rc1', true); isUpgradeableTest('1.0.0-rc1', '1.0.0', true); isUpgradeableTest('1.0.1', '1.0.0', false); + isUpgradeableTest('7.10.2', '1.1.0', true); + isUpgradeableTest('7.10.2', '2.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 d2908cf6939b..4478e6f9f526 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 @@ -75,7 +75,7 @@ export function isConfigVersionUpgradeable( // 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'); + const currentVersionIsVersion1 = semver.major(opensearchDashboardsReleaseVersion) === 1; return ( savedIsLessThanOpenSearchDashboards || (savedIsSameAsOpenSearchDashboards && savedRcIsLessThanOpenSearchDashboards) ||