Merge pull request #8769 from elastic/jasper/backport/8764/5.0

[backport] PR #8764 to 5.0 - UI Settings should be disabled when elasticsearch is not available
This commit is contained in:
Spencer 2016-10-19 17:18:23 -07:00 committed by GitHub
commit 342bf5c9ad
4 changed files with 22 additions and 1 deletions

View file

@ -18,6 +18,7 @@ module.exports = class ClusterManager {
const serverArgv = [];
const optimizerArgv = [
'--plugins.initialize=false',
'--uiSettings.enabled=false',
'--server.autoListen=false',
];

View file

@ -145,6 +145,14 @@ module.exports = () => Joi.object({
reuseTiles: Joi.boolean(),
bounds: Joi.array().items(Joi.array().items(Joi.number()).min(2).required()).min(2)
}).default()
}).default()
}).default(),
uiSettings: Joi.object({
// this is used to prevent the uiSettings from initializing. Since they
// require the elasticsearch plugin in order to function we need to turn
// them off when we turn off the elasticsearch plugin (like we do in the
// optimizer half of the dev server)
enabled: Joi.boolean().default(true)
}).default(),
}).default();

View file

@ -322,6 +322,7 @@ function instantiate({ getResult } = {}) {
const configGet = sinon.stub();
configGet.withArgs('kibana.index').returns('.kibana');
configGet.withArgs('pkg.version').returns('1.2.3-test');
configGet.withArgs('uiSettings.enabled').returns(true);
const config = {
get: configGet
};

View file

@ -3,6 +3,12 @@ import defaultsProvider from './defaults';
export default function setupSettings(kbnServer, server, config) {
const status = kbnServer.status.create('ui settings');
if (!config.get('uiSettings.enabled')) {
status.disabled('uiSettings.enabled config is set to `false`');
return;
}
const uiSettings = {
// returns a Promise for the value of the requested setting
get,
@ -99,6 +105,11 @@ export default function setupSettings(kbnServer, server, config) {
function mirrorEsStatus() {
const esStatus = kbnServer.status.getForPluginId('elasticsearch');
if (!esStatus) {
status.red('UI Settings requires the elasticsearch plugin');
return;
}
copyStatus();
esStatus.on('change', copyStatus);