Skip to content

Commit

Permalink
Merge pull request #7454 from ycombinator/gh-7424
Browse files Browse the repository at this point in the history
Mirror ES status; set own status to red if user settings are not found
  • Loading branch information
ycombinator authored Jun 15, 2016
2 parents 5b385a5 + 6222729 commit 9714484
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
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 @@ -68,7 +68,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

0 comments on commit 9714484

Please sign in to comment.