[ILM] Allow multiple searchable snapshot actions (#92789)
* remove logic that disables SS action in cold if no rollover and always show replicas field * update test coverage to be consistent with new form behaviour and expand hot phase without rollover test * only licensing can disable searchable snapshot field * clean up i18n * remove ss field callout * update error reporting logic to include causes chain, also update UI to show causes * updated searchable snapshot field in hot phase callout Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
5cc480a375
commit
cce6861b89
6 changed files with 22 additions and 31 deletions
|
@ -11,14 +11,14 @@ interface ParsedError {
|
|||
cause: string[];
|
||||
}
|
||||
|
||||
const getCause = (obj: any = {}, causes: string[] = []): string[] => {
|
||||
export const getEsCause = (obj: any = {}, causes: string[] = []): string[] => {
|
||||
const updated = [...causes];
|
||||
|
||||
if (obj.caused_by) {
|
||||
updated.push(obj.caused_by.reason);
|
||||
|
||||
// Recursively find all the "caused by" reasons
|
||||
return getCause(obj.caused_by, updated);
|
||||
return getEsCause(obj.caused_by, updated);
|
||||
}
|
||||
|
||||
return updated.filter(Boolean);
|
||||
|
@ -27,7 +27,7 @@ const getCause = (obj: any = {}, causes: string[] = []): string[] => {
|
|||
export const parseEsError = (err: string): ParsedError => {
|
||||
try {
|
||||
const { error } = JSON.parse(err);
|
||||
const cause = getCause(error);
|
||||
const cause = getEsCause(error);
|
||||
return {
|
||||
message: error.reason,
|
||||
cause,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import { ApiError } from '@elastic/elasticsearch';
|
||||
import { ResponseError } from '@elastic/elasticsearch/lib/errors';
|
||||
import { IKibanaResponse, KibanaResponseFactory } from 'kibana/server';
|
||||
import { getEsCause } from './es_error_parser';
|
||||
|
||||
interface EsErrorHandlerParams {
|
||||
error: ApiError;
|
||||
|
@ -34,7 +35,15 @@ export const handleEsError = ({
|
|||
const { statusCode, body } = error as ResponseError;
|
||||
return response.customError({
|
||||
statusCode,
|
||||
body: { message: body.error?.reason },
|
||||
body: {
|
||||
message: body.error?.reason,
|
||||
attributes: {
|
||||
// The full original ES error object
|
||||
error: body.error,
|
||||
// We assume that this is an ES error object with a nested caused by chain if we can see the "caused_by" field at the top-level
|
||||
causes: body.error?.caused_by ? getEsCause(body.error) : undefined,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
// Case: default
|
||||
|
|
|
@ -61,9 +61,6 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
|
|||
|
||||
const isColdPhase = phase === 'cold';
|
||||
const isDisabledDueToLicense = !license.canUseSearchableSnapshot();
|
||||
const isDisabledInColdDueToHotPhase = isColdPhase && isUsingSearchableSnapshotInHotPhase;
|
||||
|
||||
const isDisabled = isDisabledDueToLicense || isDisabledInColdDueToHotPhase;
|
||||
|
||||
const [isFieldToggleChecked, setIsFieldToggleChecked] = useState(() =>
|
||||
Boolean(
|
||||
|
@ -74,10 +71,10 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (isDisabled) {
|
||||
if (isDisabledDueToLicense) {
|
||||
setIsFieldToggleChecked(false);
|
||||
}
|
||||
}, [isDisabled]);
|
||||
}, [isDisabledDueToLicense]);
|
||||
|
||||
const renderField = () => (
|
||||
<SearchableSnapshotDataProvider>
|
||||
|
@ -254,7 +251,7 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
|
|||
'xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotCalloutBody',
|
||||
{
|
||||
defaultMessage:
|
||||
'Force merge, shrink, freeze and cold phase searchable snapshots are not allowed when searchable snapshots are enabled in the hot phase.',
|
||||
'Force merge, shrink and freeze actions are not allowed when searchable snapshots are enabled in this phase.',
|
||||
}
|
||||
)}
|
||||
data-test-subj="searchableSnapshotFieldsDisabledCallout"
|
||||
|
@ -278,20 +275,6 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
|
|||
)}
|
||||
</EuiCallOut>
|
||||
);
|
||||
} else if (isDisabledInColdDueToHotPhase) {
|
||||
infoCallout = (
|
||||
<EuiCallOut
|
||||
size="s"
|
||||
data-test-subj="searchableSnapshotFieldsEnabledInHotCallout"
|
||||
title={i18n.translate(
|
||||
'xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotDisabledCalloutBody',
|
||||
{
|
||||
defaultMessage:
|
||||
'Cannot create a searchable snapshot in cold when it is configured in hot phase.',
|
||||
}
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return infoCallout ? (
|
||||
|
@ -308,7 +291,7 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
|
|||
data-test-subj={`searchableSnapshotField-${phase}`}
|
||||
switchProps={{
|
||||
checked: isFieldToggleChecked,
|
||||
disabled: isDisabled,
|
||||
disabled: isDisabledDueToLicense,
|
||||
onChange: setIsFieldToggleChecked,
|
||||
'data-test-subj': 'searchableSnapshotToggle',
|
||||
label: i18n.translate(
|
||||
|
@ -339,7 +322,7 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
|
|||
fieldNotices={renderInfoCallout()}
|
||||
fullWidth
|
||||
>
|
||||
{isDisabled ? <div /> : renderField}
|
||||
{isDisabledDueToLicense ? <div /> : renderField}
|
||||
</DescribedFormRow>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -11,7 +11,10 @@ import { fatalErrors, toasts } from './notification';
|
|||
function createToastConfig(error: IHttpFetchError, errorTitle: string) {
|
||||
if (error && error.body) {
|
||||
// Error body shape is defined by the API.
|
||||
const { error: errorString, statusCode, message } = error.body;
|
||||
const { error: errorString, statusCode, message: errorMessage, attributes } = error.body;
|
||||
const message = attributes?.causes?.length
|
||||
? attributes.causes[attributes.causes.length - 1]
|
||||
: errorMessage;
|
||||
|
||||
return {
|
||||
title: errorTitle,
|
||||
|
|
|
@ -9449,8 +9449,6 @@
|
|||
"xpack.indexLifecycleMgmt.editPolicy.saveAsNewPolicyMessage": "新規ポリシーとして保存します",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.saveButton": "ポリシーを保存",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.saveErrorMessage": "ライフサイクルポリシー {lifecycleName} の保存中にエラーが発生しました",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotCalloutBody": "検索可能なスナップショットがホットフェーズで有効な場合には、強制、マージ、縮小、凍結、コールドフェーズの検索可能なスナップショットは許可されません。",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotDisabledCalloutBody": "ホットフェーズで構成されているときには、コールドフェーズで検索可能なスナップショットを作成できません。",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldDescription": "選択したリポジトリで管理されたインデックスのスナップショットを作成し、検索可能なスナップショットとしてマウントします。{learnMoreLink}。",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldLabel": "検索可能なスナップショットリポジドリ",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldTitle": "検索可能スナップショット",
|
||||
|
|
|
@ -9473,8 +9473,6 @@
|
|||
"xpack.indexLifecycleMgmt.editPolicy.saveAsNewPolicyMessage": "另存为新策略",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.saveButton": "保存策略",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.saveErrorMessage": "保存生命周期策略 {lifecycleName} 时出错",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotCalloutBody": "在热阶段启用可搜索快照时,不允许强制合并、缩小、冻结可搜索快照以及将其置入冷阶段。",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotDisabledCalloutBody": "无法在冷阶段创建在热阶段配置的可搜索快照。",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldDescription": "在所选存储库中拍取受管索引的快照,并将其安装为可搜索快照。{learnMoreLink}。",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldLabel": "可搜索快照存储库",
|
||||
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldTitle": "可搜索快照",
|
||||
|
|
Loading…
Reference in a new issue