mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[es/versionCheck] prevent spamming logs with compatibility warnings
This commit is contained in:
parent
35fc5f40a3
commit
bb95cf874c
2 changed files with 52 additions and 11 deletions
|
@ -17,7 +17,7 @@ describe('plugins/elasticsearch', () => {
|
|||
|
||||
beforeEach(function () {
|
||||
server = {
|
||||
log: _.noop,
|
||||
log: sinon.stub(),
|
||||
// This is required or else we get a SetupError.
|
||||
config: () => ({
|
||||
get: sinon.stub(),
|
||||
|
@ -95,5 +95,41 @@ describe('plugins/elasticsearch', () => {
|
|||
expect(e).to.be.a(SetupError);
|
||||
}
|
||||
});
|
||||
|
||||
it('warns if a node is only off by a patch version', async () => {
|
||||
setNodes('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('only warns once per node list', async () => {
|
||||
setNodes('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');
|
||||
|
||||
await checkEsVersion(server, KIBANA_VERSION);
|
||||
sinon.assert.callCount(server.log, 3);
|
||||
expect(server.log.getCall(2).args[0]).to.contain('debug');
|
||||
});
|
||||
|
||||
it('warns again if the node list changes', async () => {
|
||||
setNodes('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');
|
||||
|
||||
setNodes('5.1.2');
|
||||
await checkEsVersion(server, KIBANA_VERSION);
|
||||
sinon.assert.callCount(server.log, 4);
|
||||
expect(server.log.getCall(2).args[0]).to.contain('debug');
|
||||
expect(server.log.getCall(3).args[0]).to.contain('warning');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,6 +9,8 @@ import semver from 'semver';
|
|||
import isEsCompatibleWithKibana from './is_es_compatible_with_kibana';
|
||||
import SetupError from './setup_error';
|
||||
|
||||
const lastWarnedAboutNodes = new WeakMap();
|
||||
|
||||
module.exports = function checkEsVersion(server, kibanaVersion) {
|
||||
server.log(['plugin', 'debug'], 'Checking Elasticsearch version');
|
||||
|
||||
|
@ -50,16 +52,19 @@ module.exports = function checkEsVersion(server, kibanaVersion) {
|
|||
ip: node.ip,
|
||||
}));
|
||||
|
||||
server.log(['warning'], {
|
||||
tmpl: (
|
||||
'You\'re running Kibana <%= kibanaVersion %> with some newer versions of ' +
|
||||
'Elasticsearch. Update Kibana to the latest version to prevent compatibility issues: ' +
|
||||
'<%= getHumanizedNodeNames(nodes).join(", ") %>'
|
||||
),
|
||||
kibanaVersion,
|
||||
getHumanizedNodeNames,
|
||||
nodes: simplifiedNodes,
|
||||
});
|
||||
const warningNodeNames = getHumanizedNodeNames(simplifiedNodes).join(', ');
|
||||
if (lastWarnedAboutNodes.get(server) !== warningNodeNames) {
|
||||
lastWarnedAboutNodes.set(server, warningNodeNames);
|
||||
server.log(['warning'], {
|
||||
tmpl: (
|
||||
`You're running Kibana ${kibanaVersion} with some newer versions of ` +
|
||||
'Elasticsearch. Update Kibana to the latest version to prevent compatibility issues: ' +
|
||||
warningNodeNames
|
||||
),
|
||||
kibanaVersion,
|
||||
nodes: simplifiedNodes,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (incompatibleNodes.length) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue