Skip to content

Commit

Permalink
Do not crash for warning and error nodes without http published address
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Hodan authored and jbudz committed Nov 22, 2016
1 parent 31a6cba commit 89e6ded
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/core_plugins/elasticsearch/lib/__tests__/check_es_version.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ describe('plugins/elasticsearch', () => {
expect(server.log.getCall(1).args[0]).to.contain('warning');
});

it('warns if a node is without http publish address', async () => {
const nodes = { 'node-without-http': { version: '5.1.1', ip: 'ip' } };
const client = server.plugins.elasticsearch.client;
client.nodes.info = sinon.stub().returns(Promise.resolve({ nodes: nodes }));

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('only warns once per node list', async () => {
setNodes('5.1.1');

Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/elasticsearch/lib/check_es_version.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = function checkEsVersion(server, kibanaVersion) {
const simplifiedNodes = warningNodes.map(node => ({
version: node.version,
http: {
publish_address: node.http.publish_address,
publish_address: (node.http && node.http.publish_address) ? node.http.publish_address : '',
},
ip: node.ip,
}));
Expand Down

0 comments on commit 89e6ded

Please sign in to comment.