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

settings: do not query ES for settings in non-green status #9308

Merged
merged 1 commit into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/core_plugins/elasticsearch/lib/health_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,20 @@ module.exports = function (plugin, server) {
});
}

function waitForEsVersion() {
return checkEsVersion(server, kibanaVersion.get()).catch(err => {
plugin.status.red(err);
return Promise.delay(REQUEST_DELAY).then(waitForEsVersion);
});
}

function setGreenStatus() {
return plugin.status.green('Kibana index ready');
}

function check() {
return waitForPong()
.then(() => checkEsVersion(server, kibanaVersion.get()))
.then(waitForEsVersion)
.then(waitForShards)
.then(setGreenStatus)
.then(_.partial(migrateConfig, server))
Expand Down
13 changes: 11 additions & 2 deletions src/ui/settings/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ describe('ui settings', function () {
})).to.equal(true);
});

it('returns an empty object when status is not green', async function () {
const { uiSettings, req } = instantiate({
settingsStatusOverrides: { state: 'yellow' }
});

expect(await uiSettings.getUserProvided(req)).to.eql({});
});

it('returns an empty object on 404 responses', async function () {
const { uiSettings, req } = instantiate({
async callWithRequest() {
Expand Down Expand Up @@ -361,7 +369,7 @@ function expectElasticsearchUpdateQuery(server, req, configGet, doc) {
});
}

function instantiate({ getResult, callWithRequest } = {}) {
function instantiate({ getResult, callWithRequest, settingsStatusOverrides } = {}) {
const esStatus = {
state: 'green',
on: sinon.spy()
Expand All @@ -370,7 +378,8 @@ function instantiate({ getResult, callWithRequest } = {}) {
state: 'green',
red: sinon.spy(),
yellow: sinon.spy(),
green: sinon.spy()
green: sinon.spy(),
...settingsStatusOverrides
};
const kbnServer = {
status: {
Expand Down
7 changes: 7 additions & 0 deletions src/ui/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ export default function setupSettings(kbnServer, server, config) {
assertRequest(req);
const { callWithRequest, errors } = server.plugins.elasticsearch;

// If the ui settings status isn't green, we shouldn't be attempting to get
// user settings, since we can't be sure that all the necessary conditions
// (e.g. elasticsearch being available) are met.
if (status.state !== 'green') {
return hydrateUserSettings({});
}

const params = getClientSettings(config);
const allowedErrors = [errors[404], errors[403], errors.NoConnections];
if (ignore401Errors) allowedErrors.push(errors[401]);
Expand Down