Skip to content

Commit

Permalink
[ES] Handle non-semver-compliant versions (elastic#172093)
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo authored Nov 28, 2023
1 parent 8e36ba7 commit a77c4c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ describe('mapNodesVersionCompatibility', () => {
return { nodes: { 'node-without-http': { version, ip: 'ip' } } } as any;
}

it('returns isCompatible=false with a single node with non-SemVer-compliant version', async () => {
const nodesInfo = createNodes('615c621a8416c444941dc97b142a0122d5c878d0');
const result = await mapNodesVersionCompatibility(nodesInfo, KIBANA_VERSION, false);
expect(result.isCompatible).toBe(false);
});

it('returns isCompatible=true with a single node that matches', async () => {
const nodesInfo = createNodes('5.1.0');
const result = await mapNodesVersionCompatibility(nodesInfo, KIBANA_VERSION, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ describe('plugins/elasticsearch', () => {
it('when majors are equal, but ES minor is less than Kibana minor', () => {
expect(esVersionCompatibleWithKibana('1.0.0', '1.1.0')).toBe(false);
});

it('ES is not SemVer-compliant', () => {
expect(
esVersionCompatibleWithKibana('615c621a8416c444941dc97b142a0122d5c878d0', '1.1.0')
).toBe(false);
});
});

describe('returns true', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import semver, { coerce } from 'semver';
* 2. Older versions of ES won't work with newer versions of Kibana.
*/
export function esVersionCompatibleWithKibana(esVersion: string, kibanaVersion: string) {
if (!semver.valid(esVersion)) {
return false;
}

const esVersionNumbers = {
major: semver.major(esVersion),
minor: semver.minor(esVersion),
Expand Down

0 comments on commit a77c4c0

Please sign in to comment.