Skip to content

Commit

Permalink
[2.x] support legacy config (#1428)
Browse files Browse the repository at this point in the history
Allows for migrating from legacy app 6.8 to 7.10 to OSD 2.0,
without losing any settings.

Caught with BWC tests.

We should probably evalulate the strategy when we plan to split
from version sync from OpenSearch and if we want to make a
configurable matrix here. But for now making this an explicit
commit is preferable.

Issue resolved:
n/a

Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla authored Apr 13, 2022
1 parent e9e2904 commit 9489da9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ describe('plugins/opensearch', () => {
it('when majors and minors are not equal, but the engine is on legacy version 8.0.0 and OpenSearch Dashboards is on 1.0.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('8.0.0', '1.0.0')).toBe(false);
});

it('when majors and minors are not equal, but the engine is on legacy version 6.10.3 and OpenSearch Dashboards is on 2.0.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('6.10.3', '2.0.0')).toBe(false);
});

it('when majors and minors are not equal, but the engine is on legacy version 7.10.3 and OpenSearch Dashboards is on 2.0.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('7.10.3', '2.0.0')).toBe(false);
});

it('when majors and minors are not equal, but the engine is on legacy version 8.0.0 and OpenSearch Dashboards is on 2.0.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('8.0.0', '2.0.0')).toBe(false);
});
});

describe('returns true', () => {
Expand Down Expand Up @@ -86,6 +98,18 @@ describe('plugins/opensearch', () => {
it('when majors and minors are not equal, but the engine is on legacy version 7.10.2 and OpenSearch Dashboards is on 1.1.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('7.10.2', '1.1.0')).toBe(true);
});

it('when majors and minors are not equal, but the engine is on legacy version 7.10.2 and OpenSearch Dashboards is on 2.0.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('7.10.2', '2.0.0')).toBe(true);
});

it('when majors and minors are not equal, but the engine is on legacy version 7.10.2 and OpenSearch Dashboards is on 2.0.1', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('7.10.2', '2.0.1')).toBe(true);
});

it('when majors and minors are not equal, but the engine is on legacy version 7.10.2 and OpenSearch Dashboards is on 2.1.0', () => {
expect(opensearchVersionCompatibleWithOpenSearchDashboards('7.10.2', '2.1.0')).toBe(true);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ interface VersionNumbers {
patch: number;
}

/**
* @private
*
* List of OpenSearch Dashboards major versions that can connect to legacy version
* 7.10.2.
*
* WARNING: OpenSearchDashboards 7.x could cause conflicts.
*/
const osdLegacyCompatibleMajorVersions = [1, 2];

/**
* Checks for the compatibilitiy between OpenSearch and OpenSearchDashboards versions
* 1. Major version differences will never work together.
Expand Down Expand Up @@ -110,6 +120,6 @@ function legacyVersionCompatibleWithOpenSearchDashboards(
legacyVersionNumbers.major === 7 &&
legacyVersionNumbers.minor === 10 &&
legacyVersionNumbers.patch === 2 &&
opensearchDashboardsVersionNumbers.major === 1
osdLegacyCompatibleMajorVersions.includes(opensearchDashboardsVersionNumbers.major)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,6 @@ describe('savedObjects/health_check/isConfigVersionUpgradeable', function () {
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);
isUpgradeableTest('7.10.2', '2.0.0', true);
isUpgradeableTest('7.10.2', '3.0.0', false);
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
*/

import semver from 'semver';
/**
* List of OpenSearch Dashboards major versions that can pull the
* config from a legacy version that is higher in semvar.
*
* WARNING: OpenSearchDashboards 7.x could cause conflicts.
*/
const osdValidMajorVersions = [1, 2];
const rcVersionRegex = /^(\d+\.\d+\.\d+)\-rc(\d+)$/i;

function extractRcNumber(version: string): [string, number] {
Expand Down Expand Up @@ -73,10 +80,12 @@ 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.major(opensearchDashboardsReleaseVersion) === 1;
const currentVersionIsValidOSDVersion = osdValidMajorVersions.includes(
semver.major(opensearchDashboardsReleaseVersion)
);
return (
savedIsLessThanOpenSearchDashboards ||
(savedIsSameAsOpenSearchDashboards && savedRcIsLessThanOpenSearchDashboards) ||
(savedIsFromPrefork && currentVersionIsVersion1)
(savedIsFromPrefork && currentVersionIsValidOSDVersion)
);
}

0 comments on commit 9489da9

Please sign in to comment.