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

Mirror ES status; set own status to red if user settings are not found #7454

Merged
merged 9 commits into from
Jun 15, 2016
2 changes: 1 addition & 1 deletion src/cli/serve/__tests__/reload_logging_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ${err.stack || err.message || err}`).to.eql(true);
}

function switchToPlainTextLog() {
json = 2; // ignore both "reloading" messages
json = 3; // ignore both "reloading" messages + ui settings status message
setLoggingJson(false);
child.kill(`SIGHUP`); // reload logging config
}
Expand Down
21 changes: 16 additions & 5 deletions src/ui/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defaultsDeep, partial } from 'lodash';
import defaultsProvider from './defaults';

export default function setupSettings(kbnServer, server, config) {
const status = kbnServer.status.create('ui settings');
const uiSettings = {
getAll,
getDefaults,
Expand All @@ -12,6 +13,7 @@ export default function setupSettings(kbnServer, server, config) {
};

server.decorate('server', 'uiSettings', () => uiSettings);
kbnServer.ready().then(mirrorEsStatus);

function getAll() {
return Promise
Expand All @@ -24,11 +26,7 @@ export default function setupSettings(kbnServer, server, config) {
}

function userSettingsNotFound(kibanaVersion) {
if (server.plugins.elasticsearch.status.state === 'green') {
server.plugins.kibana.status.red(`Could not find user-provided settings for this version of Kibana (${kibanaVersion})`);
} else {
server.log(['warning', 'settings'], 'User-provided settings were requested before the Kibana index was ready');
}
status.red(`Could not find user-provided settings for Kibana ${kibanaVersion}`);
return {};
}

Expand Down Expand Up @@ -60,6 +58,19 @@ export default function setupSettings(kbnServer, server, config) {
function remove(key) {
return set(key, null);
}

function mirrorEsStatus() {
const esStatus = kbnServer.status.getForPluginId('elasticsearch');

copyStatus();
esStatus.on('change', copyStatus);

function copyStatus() {
const { state } = esStatus;
const statusMessage = state === 'green' ? 'Ready' : `Elasticsearch plugin is ${state}`;
status[state](statusMessage);
}
}
}

function hydrateUserSettings(user) {
Expand Down