From 057056dc3d19e892f1488ffb5ce3208583f1b931 Mon Sep 17 00:00:00 2001 From: Pierre Padovani Date: Wed, 8 Aug 2018 08:16:13 -0500 Subject: [PATCH] Fix #58... retry for up to five times to attempt to modify kibana index (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) --- index.js | 40 ++++++++++++++++++++++++---------------- package.json | 5 +++-- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index c74b91f..514da25 100644 --- a/index.js +++ b/index.js @@ -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({ @@ -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}', diff --git a/package.json b/package.json index 5d6cc3a..0e4d0c9 100644 --- a/package.json +++ b/package.json @@ -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": [ @@ -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",