diff --git a/src/core_plugins/elasticsearch/lib/__tests__/check_es_version.js b/src/core_plugins/elasticsearch/lib/__tests__/check_es_version.js index 74d43816d8384..cc36d350d6eb0 100644 --- a/src/core_plugins/elasticsearch/lib/__tests__/check_es_version.js +++ b/src/core_plugins/elasticsearch/lib/__tests__/check_es_version.js @@ -56,6 +56,12 @@ describe('plugins/elasticsearch', () => { client.nodes.info = sinon.stub().returns(Promise.resolve({ nodes: nodes })); } + function setNodeWithoutHTTP(version) { + const nodes = { 'node-without-http': { version, ip: 'ip' } }; + const client = server.plugins.elasticsearch.client; + client.nodes.info = sinon.stub().returns(Promise.resolve({ nodes: nodes })); + } + it('returns true with single a node that matches', async () => { setNodes('5.1.0'); const result = await checkEsVersion(server, KIBANA_VERSION); @@ -99,6 +105,24 @@ describe('plugins/elasticsearch', () => { expect(server.log.getCall(1).args[0]).to.contain('warning'); }); + it('warns if a node is off by a patch version and without http publish address', async () => { + setNodeWithoutHTTP('5.1.1'); + await checkEsVersion(server, KIBANA_VERSION); + sinon.assert.callCount(server.log, 2); + expect(server.log.getCall(0).args[0]).to.contain('debug'); + expect(server.log.getCall(1).args[0]).to.contain('warning'); + }); + + it('errors if a node incompatible and without http publish address', async () => { + setNodeWithoutHTTP('6.1.1'); + try { + await checkEsVersion(server, KIBANA_VERSION); + } catch (e) { + expect(e.message).to.contain('incompatible nodes'); + expect(e).to.be.a(Error); + } + }); + it('only warns once per node list', async () => { setNodes('5.1.1'); diff --git a/src/core_plugins/elasticsearch/lib/check_es_version.js b/src/core_plugins/elasticsearch/lib/check_es_version.js index b9eddd0e0f249..a6cc89978ac9b 100644 --- a/src/core_plugins/elasticsearch/lib/check_es_version.js +++ b/src/core_plugins/elasticsearch/lib/check_es_version.js @@ -44,7 +44,8 @@ module.exports = function checkEsVersion(server, kibanaVersion) { function getHumanizedNodeNames(nodes) { return nodes.map(node => { - return 'v' + node.version + ' @ ' + node.http.publish_address + ' (' + node.ip + ')'; + const publishAddress = _.get(node, 'http.publish_address') ? (_.get(node, 'http.publish_address') + ' ') : ''; + return 'v' + node.version + ' @ ' + publishAddress + '(' + node.ip + ')'; }); } @@ -52,7 +53,7 @@ module.exports = function checkEsVersion(server, kibanaVersion) { const simplifiedNodes = warningNodes.map(node => ({ version: node.version, http: { - publish_address: node.http.publish_address, + publish_address: _.get(node, 'http.publish_address') }, ip: node.ip, })); @@ -78,7 +79,7 @@ module.exports = function checkEsVersion(server, kibanaVersion) { throw new Error( `This version of Kibana requires Elasticsearch v` + `${kibanaVersion} on all nodes. I found ` + - `the following incompatible nodes in your cluster: ${incompatibleNodeNames.join(',')}` + `the following incompatible nodes in your cluster: ${incompatibleNodeNames.join(', ')}` ); }