Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Prevent crashing from incompatible nodes without http when logging #9207

Merged
merged 1 commit into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 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 @@ -61,6 +61,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);
Expand Down Expand Up @@ -104,6 +110,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');

Expand Down
7 changes: 4 additions & 3 deletions src/core_plugins/elasticsearch/lib/check_es_version.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ 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 + ')';
});
}

if (warningNodes.length) {
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,
}));
Expand All @@ -80,7 +81,7 @@ module.exports = function checkEsVersion(server, kibanaVersion) {
const errorMessage =
`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(', ')}`;

throw new SetupError(server, errorMessage);
}
Expand Down