-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Don't turn Kibana plugin red if Kibana index is not yet ready #7428
Changes from 3 commits
a2459bb
ab66d5e
e860fc3
3ebf365
aa05237
db780bd
58f9843
3425818
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import uiModules from 'ui/modules'; | |
|
||
const chrome = require('ui/chrome') | ||
.setRootTemplate(require('plugins/status_page/status_page.html')) | ||
.setRootController('ui', function ($http, $scope) { | ||
.setRootController('ui', function ($http, $window, $scope) { | ||
const ui = this; | ||
ui.loading = false; | ||
|
||
|
@@ -36,6 +36,14 @@ const chrome = require('ui/chrome') | |
ui.serverState = overall.state; | ||
ui.serverStateMessage = overall.title; | ||
} | ||
|
||
// Unless the status page was explicitly requested, there is no | ||
// reason to stay on the status page if the status is green; reload | ||
// the window so the user is shown the page they were requesting. | ||
const statusPageUrl = chrome.addBasePath('/status'); | ||
if ((overall.state === 'green') && ($window.location.pathname !== statusPageUrl)) { | ||
return $window.location.reload(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This bit of code is necessary for the following scenario: If I tried to load up Kibana in the browser while the server was still starting up, and the Kibana index wasn't yet ready (i.e. the Elasticsearch plugin wasn't yet green), I was taken to the Status page. However, by the time the Status page was actually rendered, the Kibana index was ready and all the plugins had turned green. In such cases, rather than show the user a Status page where everything is green, I think it makes sense to reload the window so they are taken to wherever they meant to go. Happy to remove this code if folks disagree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I disagree with this approach. The issue here is a race condition caused by legacy code from back when the status page automatically refreshed. I think the right thing to do here is get rid of the race condition and send the status information to the browser with the app code, rather than fetching it on page load. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @spalger. Are you okay with me filing a separate issue to fix this, rather than adding to the scope of this PR? I will, of course, remove this reloading code block from this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}) | ||
.catch(function () { | ||
if (ui.fetchError) return; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,16 @@ export default function setupSettings(kbnServer, server, config) { | |
} | ||
|
||
function userSettingsNotFound(kibanaVersion) { | ||
const message = 'Could not find user-provided settings for this version of Kibana (' + kibanaVersion + ')'; | ||
server.plugins.kibana.status.red(message); | ||
let message; | ||
if (server.plugins.elasticsearch.status.state === 'green') { | ||
// If Kibana index is ready but we still couldn't find user-provided settings in it, | ||
// turn Kibana plugin to red | ||
server.plugins.kibana.status.red('Could not find user-provided settings for this version of Kibana (' + kibanaVersion + ')'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change the message into a template string? Also the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally. And good catch on the unused |
||
} else { | ||
// Otherwise, simply log a warning because a page refresh (once the Kibana index is ready) will | ||
// solve the problem | ||
server.log(['warning', 'settings'], 'User-provided settings were requested before the Kibana index was ready'); | ||
} | ||
return {}; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd get rid of the extra parenthesis here
(overall.state === 'green' && $window.location.pathname !== statusPageUrl)
is good enough