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

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

Merged
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

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';
2 changes: 1 addition & 1 deletion src/ui/public/promises/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module.service('Promise', function ($q, $timeout) {
return obj && typeof obj.then === 'function';
};
Promise.halt = _.once(function () {
const promise = new Promise();
const promise = new Promise(() => {});
promise.then = _.constant(promise);
promise.catch = _.constant(promise);
return promise;
Expand Down