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
16 changes: 11 additions & 5 deletions src/ui/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@ 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');
}
server.plugins.kibana.status.yellow(`Could not find user-provided settings for this version of Kibana (${kibanaVersion})`);
return {};
}

function resetKibanaPluginStatusIfNecessary(user) {
const isElasticsearchPluginGreen = server.plugins.elasticsearch.status.state === 'green';
const isKibanaPluginCurrentlyYellow = server.plugins.kibana.status.state === 'yellow';
if (isElasticsearchPluginGreen && isKibanaPluginCurrentlyYellow) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if server.plugins.kibana.status.state === 'red' ? Does code somewhere else change it from red to yellow, and then this changes it yellow to green?

Copy link
Contributor

@bevacqua bevacqua Jun 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point Lee. I really think all we ought to do when user settings are not found is set the Elastiscearch plugin status to yellow, because ultimately that's the plugin responsible for (re)creating the .kibana index and going green again when the index is ready. I think we shouldn't muck with the Kibana plugin status at all. Thoughts?

server.plugins.kibana.status.green('Ready');
}
return user;
}

function getUserProvided() {
const { client } = server.plugins.elasticsearch;
const clientSettings = getClientSettings(config);
return client
.get({ ...clientSettings })
.then(res => res._source)
.then(resetKibanaPluginStatusIfNecessary)
.catch(partial(userSettingsNotFound, clientSettings.id))
.then(user => hydrateUserSettings(user));
}
Expand Down