Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2309 from sirensolutions/backport-2306-463
Browse files Browse the repository at this point in the history
Fix upgrade, bump version
  • Loading branch information
fabiocorneti committed Feb 14, 2017
2 parents 7a734b9 + 8a2bbe1 commit e965189
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Kibi 4.6.3-1
# Kibi 4.6.3-2

Kibi extends Kibana 4.6.3 with data intelligence features; the core feature of
Kibi is the capability to join and filter data from multiple Elasticsearch
Expand Down
2 changes: 1 addition & 1 deletion docs/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:siren-join-website: https://github.com/sirensolutions/siren-join/
:kibana-version: 4.6.3
:kibana-announcement: https://www.elastic.co/blog/kibana-5-0-1-and-4-6-3-released
:kibi-version: 4.6.3-1
:kibi-version: 4.6.3-2
:elastic-ref: https://www.elastic.co/guide/en/elasticsearch/reference/2.4/
:elasticsearch-version: 2.4.1
:shield-ref: https://www.elastic.co/guide/en/shield/2.4/
Expand Down
2 changes: 2 additions & 0 deletions docs/releasenotes.asciidoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[[releasenotes]]
== Kibi Release Notes

include::releasenotes_4.6.3-2.asciidoc[]

include::releasenotes_4.6.3-1.asciidoc[]

include::releasenotes_4.6.3.asciidoc[]
Expand Down
7 changes: 7 additions & 0 deletions docs/releasenotes_4.6.3-2.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
=== Kibi 4.6.3-2 Release Notes

==== Kibi Changes

* Added - Graphs can be saved

* Fixed - Migrations from 4.6.3 to 4.6.3-2
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"private": false,
"version": "4.6.3",
"kibi_kibana_announcement": "https://www.elastic.co/blog/kibana-5-0-1-and-4-6-3-released",
"kibi_version": "4.6.3-1",
"kibi_version": "4.6.3-2",
"kibi_enterprise_enabled": false,
"build": {
"number": 8467,
Expand Down
3 changes: 1 addition & 2 deletions src/migrations/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export default class Migration {
}

let response = await this._client.search(searchOptions);
let scrollId = response._scroll_id;

while (true) {
objects.push(...response.hits.hits);
Expand All @@ -75,7 +74,7 @@ export default class Migration {
}
response = await this._client.scroll({
scroll: '1m',
scroll_id: scrollId
scroll_id: response._scroll_id
});
}

Expand Down
14 changes: 14 additions & 0 deletions src/plugins/elasticsearch/lib/__tests__/is_upgradeable.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ describe('plugins/elasticsearch', function () {
upgradeDoc('4.0.0-rc1', '4.0.0', true);
upgradeDoc('4.0.0-rc1-snapshot', '4.0.0', false);
upgradeDoc('4.1.0-rc1-snapshot', '4.1.0-rc1', false);
// kibi: additional tests
upgradeDoc('4.6.3', '4.6.4', true);

// kibi: support upgrade from a release to a snapshot
upgradeDoc('4.5.4', '4.5.4-SNAPSHOT', true);
Expand All @@ -58,6 +60,18 @@ describe('plugins/elasticsearch', function () {
upgradeDoc('4.5.4-beta2', '4.5.4-beta-3', true);
upgradeDoc('4.5.4-beta-4', '4.5.4-rc-1', true);

// kibi: dash upgrades
upgradeDoc('4.6.3', '4.6.3-1', true);
upgradeDoc('4.5.4', '4.5.4-1', true);
upgradeDoc('4.6.3-1', '4.6.3', false);
upgradeDoc('4.6.3-1', '4.6.3-2', true);
upgradeDoc('4.6.3', '4.6.4-1', true);
upgradeDoc('4.5.4-1', '4.5.4', false);
upgradeDoc('4.5.4-1', '4.6.3-1', true);
upgradeDoc('4.5.4-beta-2', '4.6.3-1', true);
upgradeDoc('4.5.3-1', '4.5.3-6', true);
upgradeDoc('4.5.3', '4.5.3-6', true);

it('should handle missing _id field', function () {
let doc = {
'_index': '.kibi',
Expand Down
31 changes: 30 additions & 1 deletion src/plugins/elasticsearch/lib/is_upgradeable.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ function computePreReleaseIndex(matches) {
];
}

/**
* Some Kibi versions use the dash, which is considered a pre-release by semver.
*/
function lowerThan(version, packageVersion) {
const dashRe = /^(\d\.\d\.\d)-(\d?)$/;
let semVersion = version;
let versionIncrement = 0;
let semPackageVersion = packageVersion;
let packageVersionIncrement = 0;

let matches = version.match(dashRe);
if (matches) {
semVersion = matches[1];
versionIncrement = parseInt(matches[2], 10);
}

matches = packageVersion.match(dashRe);
if (matches) {
semPackageVersion = matches[1];
packageVersionIncrement = parseInt(matches[2], 10);
}

if (semver.eq(semVersion, semPackageVersion)) {
return versionIncrement < packageVersionIncrement;
}
return semver.lt(version, packageVersion);
}

module.exports = function (server, doc) {
const config = server.config();
if (/snapshot/i.test(doc._id)) return false;
Expand Down Expand Up @@ -56,7 +84,8 @@ module.exports = function (server, doc) {
if (semver.eq(version, packageVersion)) {
return isSnapshot || preReleaseIndex < packagePreReleaseIndex;
}
return semver.lt(version, packageVersion);
// kibi: handle dash versions
return lowerThan(version, packageVersion);
} catch (e) {
return false;
}
Expand Down

0 comments on commit e965189

Please sign in to comment.