Skip to content

Commit

Permalink
Fix #58... retry for up to five times to attempt to modify kibana index
Browse files Browse the repository at this point in the history
(cherry picked from commit 007ff15)

(cherry picked from commit bbae238)

(cherry picked from commit 65eb777)

Fix #58, retry forever

(cherry picked from commit eea73a4)

(cherry picked from commit 198329a)

(cherry picked from commit c38ef3f)

(cherry picked from commit 3a8725d)

(cherry picked from commit 67d557b)
  • Loading branch information
Pierre Padovani committed Aug 11, 2018
1 parent e177222 commit 057056d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
40 changes: 24 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
import {resolve} from 'path';
import Promise from 'bluebird';

function updateIndexSchema(callWithInternalUser, server) {
return callWithInternalUser('indices.putMapping', {
index: server.config().get('kibana.index'),
type: "doc",
body: {
properties: {
"index-pattern": {
properties: {
nested: {
type: "boolean"
}
}
}
}
}
}).catch(function (err) {
return Promise.delay(10).then(updateIndexSchema.bind(null, callWithInternalUser, server));
});
}


export default function (kibana) {
return new kibana.Plugin({
Expand Down Expand Up @@ -30,23 +52,9 @@ export default function (kibana) {

// Update the .kibana index-pattern type to include a new nested flag
init(server, options) {
const {callWithInternalUser} = server.plugins.elasticsearch.getCluster('admin');
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin');

callWithInternalUser('indices.putMapping', {
index: server.config().get('kibana.index'),
type: "doc",
body: {
properties: {
"index-pattern": {
properties: {
nested: {
type: "boolean"
}
}
}
}
}
});
updateIndexSchema(callWithInternalUser, server);

server.route({
path: '/api/nested-fields-support/mappings/{name}',
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nested-fields-support",
"version": "6.2.4-1.0.5",
"version": "6.2.4-1.0.6",
"description": "Nested Support Plugin",
"license": "Apache-2.0",
"authors": [
Expand All @@ -25,7 +25,8 @@
"gather-info": "node gather-info.js"
},
"dependencies": {
"lodash": "3.10.1"
"lodash": "3.10.1",
"bluebird": "2.9.34"
},
"devDependencies": {
"@elastic/eslint-config-kibana": "^0.14.0",
Expand Down

0 comments on commit 057056d

Please sign in to comment.