Skip to content

Commit

Permalink
[errors/multi.allow_explicit_index] move error handling to browser (e…
Browse files Browse the repository at this point in the history
…lastic#14184)

* [errors/multi.allow_explicit_index] move error handling to browser

A part of elastic#14163, this removes the portion of the healthCheck that tries to verify that rest.action.multi.allow_explicit_index is not set to false. Instead, a ui module was created that will check errors from elasticsearch for this specific scenario, and exposes a method that will display a nicer "fatal error" screen that informs the user about what they should do, and navigates away from the now broken app.

* [es/healthCheck] remove old test

* fix typo
  • Loading branch information
spalger authored and chrisronline committed Dec 1, 2017
1 parent 25abdd1 commit 83f31ec
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 117 deletions.

This file was deleted.

36 changes: 0 additions & 36 deletions src/core_plugins/elasticsearch/lib/ensure_allow_explicit_index.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/core_plugins/elasticsearch/lib/health_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import createKibanaIndex from './create_kibana_index';
import kibanaVersion from './kibana_version';
import { ensureEsVersion } from './ensure_es_version';
import { ensureNotTribe } from './ensure_not_tribe';
import { ensureAllowExplicitIndex } from './ensure_allow_explicit_index';
import { patchKibanaIndex } from './patch_kibana_index';

const NoConnections = elasticsearch.errors.NoConnections;
Expand Down Expand Up @@ -101,7 +100,6 @@ export default function (plugin, server) {
waitForPong(callAdminAsKibanaUser, config.get('elasticsearch.url'))
.then(waitForEsVersion)
.then(() => ensureNotTribe(callAdminAsKibanaUser))
.then(() => ensureAllowExplicitIndex(callAdminAsKibanaUser, config))
.then(waitForShards)
.then(() => patchKibanaIndex({
callCluster: callAdminAsKibanaUser,
Expand Down
13 changes: 9 additions & 4 deletions src/ui/public/courier/fetch/call_client.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import _ from 'lodash';

import { ErrorAllowExplicitIndexProvider } from 'ui/error_allow_explicit_index';
import { IsRequestProvider } from './is_request';
import { MergeDuplicatesRequestProvider } from './merge_duplicate_requests';
import { ReqStatusProvider } from './req_status';

export function CallClientProvider(Private, Promise, es) {

const errorAllowExplicitIndex = Private(ErrorAllowExplicitIndexProvider);
const isRequest = Private(IsRequestProvider);
const mergeDuplicateRequests = Private(MergeDuplicatesRequestProvider);

Expand Down Expand Up @@ -121,9 +122,13 @@ export function CallClientProvider(Private, Promise, es) {
return strategy.getResponses(clientResp);
})
.then(respond)
.catch(function (err) {
if (err === ABORTED) respond();
else defer.reject(err);
.catch(function (error) {
if (errorAllowExplicitIndex.test(error)) {
return errorAllowExplicitIndex.takeover();
}

if (error === ABORTED) respond();
else defer.reject(error);
});

// return our promise, but catch any errors we create and
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="app-container error-multi-allow-explicit-index">
<h3>
<i aria-hidden="true" class="fa fa-warning text-danger"></i> Oh no!
</h3>
<p>
It looks like your Elasticsearch cluster has the <code>rest.action.multi.allow_explicit_index</code> setting set to <code>false</code>, which prevents Kibana from making search requests. We use this ability to send a single request to Elasticsearch that searches multiple indexes so that when there are many panels on a dashboard they will load quickly and uniformly.
</p>

<p>
Unfortunately, until this issue is fixed you won't be able to use certain apps in Kibana, like Discover, Visualize and Dashboard.
</p>

<h3>Ok, how do I fix this?</h3>
<ol>
<li>Remove <code>rest.action.multi.allow_explicit_index: false</code> from your Elasticsearch config file.</li>
<li>Restart Elasticsearch.</li>
<li>Use the browser's back button to return to what you were doing.</li>
</ol>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { get } from 'lodash';

import uiRoutes from 'ui/routes';
import { KbnUrlProvider } from 'ui/url';

import './error_allow_explicit_index.less';
import template from './error_allow_explicit_index.html';

uiRoutes
.when('/error/multi.allow_explicit_index', { template });

export function ErrorAllowExplicitIndexProvider(Private, Promise) {
const kbnUrl = Private(KbnUrlProvider);

return new class ErrorAllowExplicitIndex {
test(error) {
if (!error || error.status !== 400) {
return false;
}

const type = get(error, 'body.error.type');
const reason = get(error, 'body.error.reason');

return (
type === 'illegal_argument_exception' &&
String(reason).includes('explicit index')
);
}

takeover() {
kbnUrl.change('/error/multi.allow_explicit_index');
return Promise.halt();
}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.error-multi-allow-explicit-index {
padding: 25px;
}
1 change: 1 addition & 0 deletions src/ui/public/error_allow_explicit_index/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ErrorAllowExplicitIndexProvider } from './error_allow_explicit_index';

0 comments on commit 83f31ec

Please sign in to comment.