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

[7.x] Add modal with details to shard error toast (#41649) #42227

Merged
merged 1 commit into from
Jul 30, 2019
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
1 change: 1 addition & 0 deletions src/core/public/overlays/overlay_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export interface OverlayStart {
openModal: (
modalChildren: React.ReactNode,
modalProps?: {
className?: string;
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
}
Expand Down
1 change: 1 addition & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ export interface OverlayStart {
}) => OverlayRef;
// (undocumented)
openModal: (modalChildren: React.ReactNode, modalProps?: {
className?: string;
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
}) => OverlayRef;
Expand Down
1 change: 1 addition & 0 deletions src/legacy/ui/public/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@import './accessibility/index';
@import './chrome/index';
@import './courier/index';
@import './collapsible_sidebar/index';
@import './directives/index';
@import './error_allow_explicit_index/index';
Expand Down
1 change: 1 addition & 0 deletions src/legacy/ui/public/courier/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import './fetch/components/shard_failure_modal';
43 changes: 35 additions & 8 deletions src/legacy/ui/public/courier/fetch/call_response_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiSpacer } from '@elastic/eui';
import { toastNotifications } from '../../notify';
import { RequestFailure } from '../../errors';
import { RequestStatus } from './req_status';
import { SearchError } from '../search_strategy/search_error';
import { i18n } from '@kbn/i18n';
import { ShardFailureOpenModalButton } from './components/shard_failure_open_modal_button';

export function CallResponseHandlersProvider(Promise) {
const ABORTED = RequestStatus.ABORTED;
Expand All @@ -39,16 +41,37 @@ export function CallResponseHandlersProvider(Promise) {
toastNotifications.addWarning({
title: i18n.translate('common.ui.courier.fetch.requestTimedOutNotificationMessage', {
defaultMessage: 'Data might be incomplete because your request timed out',
})
}),
});
}

if (response._shards && response._shards.failed) {
const title = i18n.translate('common.ui.courier.fetch.shardsFailedNotificationMessage', {
defaultMessage: '{shardsFailed} of {shardsTotal} shards failed',
values: {
shardsFailed: response._shards.failed,
shardsTotal: response._shards.total,
},
});
const description = i18n.translate('common.ui.courier.fetch.shardsFailedNotificationDescription', {
defaultMessage: 'The data you are seeing might be incomplete or wrong.',
});

const text = (
<>
{description}
<EuiSpacer size="s"/>
<ShardFailureOpenModalButton
request={searchRequest.fetchParams.body}
response={response}
title={title}
/>
</>
);

toastNotifications.addWarning({
title: i18n.translate('common.ui.courier.fetch.shardsFailedNotificationMessage', {
defaultMessage: '{shardsFailed} of {shardsTotal} shards failed',
values: { shardsFailed: response._shards.failed, shardsTotal: response._shards.total }
})
title,
text,
});
}

Expand All @@ -65,7 +88,11 @@ export function CallResponseHandlersProvider(Promise) {
if (searchRequest.filterError(response)) {
return progress();
} else {
return searchRequest.handleFailure(response.error instanceof SearchError ? response.error : new RequestFailure(null, response));
return searchRequest.handleFailure(
response.error instanceof SearchError
? response.error
: new RequestFailure(null, response)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { Request } from '../shard_failure_types';
export const shardFailureRequest = {
version: true,
size: 500,
sort: [],
_source: {
excludes: [],
},
stored_fields: ['*'],
script_fields: {},
docvalue_fields: [],
query: {},
highlight: {},
} as Request;
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { ResponseWithShardFailure } from '../shard_failure_types';

export const shardFailureResponse = {
_shards: {
total: 2,
successful: 1,
skipped: 0,
failed: 1,
failures: [
{
shard: 0,
index: 'repro2',
node: 'itsmeyournode',
reason: {
type: 'script_exception',
reason: 'runtime error',
script_stack: ["return doc['targetfield'].value;", ' ^---- HERE'],
script: "return doc['targetfield'].value;",
lang: 'painless',
caused_by: {
type: 'illegal_argument_exception',
reason: 'Gimme reason',
},
},
},
],
},
} as ResponseWithShardFailure;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading