Skip to content

Commit dff54d7

Browse files
[ILM] Allow multiple searchable snapshot actions (#92789) (#93242)
* 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> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 395f0f5 commit dff54d7

6 files changed

Lines changed: 22 additions & 31 deletions

File tree

src/plugins/es_ui_shared/__packages_do_not_import__/errors/es_error_parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ interface ParsedError {
1111
cause: string[];
1212
}
1313

14-
const getCause = (obj: any = {}, causes: string[] = []): string[] => {
14+
export const getEsCause = (obj: any = {}, causes: string[] = []): string[] => {
1515
const updated = [...causes];
1616

1717
if (obj.caused_by) {
1818
updated.push(obj.caused_by.reason);
1919

2020
// Recursively find all the "caused by" reasons
21-
return getCause(obj.caused_by, updated);
21+
return getEsCause(obj.caused_by, updated);
2222
}
2323

2424
return updated.filter(Boolean);
@@ -27,7 +27,7 @@ const getCause = (obj: any = {}, causes: string[] = []): string[] => {
2727
export const parseEsError = (err: string): ParsedError => {
2828
try {
2929
const { error } = JSON.parse(err);
30-
const cause = getCause(error);
30+
const cause = getEsCause(error);
3131
return {
3232
message: error.reason,
3333
cause,

src/plugins/es_ui_shared/__packages_do_not_import__/errors/handle_es_error.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { ApiError } from '@elastic/elasticsearch';
1010
import { ResponseError } from '@elastic/elasticsearch/lib/errors';
1111
import { IKibanaResponse, KibanaResponseFactory } from 'kibana/server';
12+
import { getEsCause } from './es_error_parser';
1213

1314
interface EsErrorHandlerParams {
1415
error: ApiError;
@@ -34,7 +35,15 @@ export const handleEsError = ({
3435
const { statusCode, body } = error as ResponseError;
3536
return response.customError({
3637
statusCode,
37-
body: { message: body.error?.reason },
38+
body: {
39+
message: body.error?.reason,
40+
attributes: {
41+
// The full original ES error object
42+
error: body.error,
43+
// 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
44+
causes: body.error?.caused_by ? getEsCause(body.error) : undefined,
45+
},
46+
},
3847
});
3948
}
4049
// Case: default

x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/searchable_snapshot_field/searchable_snapshot_field.tsx

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
6161

6262
const isColdPhase = phase === 'cold';
6363
const isDisabledDueToLicense = !license.canUseSearchableSnapshot();
64-
const isDisabledInColdDueToHotPhase = isColdPhase && isUsingSearchableSnapshotInHotPhase;
65-
66-
const isDisabled = isDisabledDueToLicense || isDisabledInColdDueToHotPhase;
6764

6865
const [isFieldToggleChecked, setIsFieldToggleChecked] = useState(() =>
6966
Boolean(
@@ -74,10 +71,10 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
7471
);
7572

7673
useEffect(() => {
77-
if (isDisabled) {
74+
if (isDisabledDueToLicense) {
7875
setIsFieldToggleChecked(false);
7976
}
80-
}, [isDisabled]);
77+
}, [isDisabledDueToLicense]);
8178

8279
const renderField = () => (
8380
<SearchableSnapshotDataProvider>
@@ -254,7 +251,7 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
254251
'xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotCalloutBody',
255252
{
256253
defaultMessage:
257-
'Force merge, shrink, freeze and cold phase searchable snapshots are not allowed when searchable snapshots are enabled in the hot phase.',
254+
'Force merge, shrink and freeze actions are not allowed when searchable snapshots are enabled in this phase.',
258255
}
259256
)}
260257
data-test-subj="searchableSnapshotFieldsDisabledCallout"
@@ -278,20 +275,6 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
278275
)}
279276
</EuiCallOut>
280277
);
281-
} else if (isDisabledInColdDueToHotPhase) {
282-
infoCallout = (
283-
<EuiCallOut
284-
size="s"
285-
data-test-subj="searchableSnapshotFieldsEnabledInHotCallout"
286-
title={i18n.translate(
287-
'xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotDisabledCalloutBody',
288-
{
289-
defaultMessage:
290-
'Cannot create a searchable snapshot in cold when it is configured in hot phase.',
291-
}
292-
)}
293-
/>
294-
);
295278
}
296279

297280
return infoCallout ? (
@@ -308,7 +291,7 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
308291
data-test-subj={`searchableSnapshotField-${phase}`}
309292
switchProps={{
310293
checked: isFieldToggleChecked,
311-
disabled: isDisabled,
294+
disabled: isDisabledDueToLicense,
312295
onChange: setIsFieldToggleChecked,
313296
'data-test-subj': 'searchableSnapshotToggle',
314297
label: i18n.translate(
@@ -339,7 +322,7 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
339322
fieldNotices={renderInfoCallout()}
340323
fullWidth
341324
>
342-
{isDisabled ? <div /> : renderField}
325+
{isDisabledDueToLicense ? <div /> : renderField}
343326
</DescribedFormRow>
344327
);
345328
};

x-pack/plugins/index_lifecycle_management/public/application/services/api_errors.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import { fatalErrors, toasts } from './notification';
1111
function createToastConfig(error: IHttpFetchError, errorTitle: string) {
1212
if (error && error.body) {
1313
// Error body shape is defined by the API.
14-
const { error: errorString, statusCode, message } = error.body;
14+
const { error: errorString, statusCode, message: errorMessage, attributes } = error.body;
15+
const message = attributes?.causes?.length
16+
? attributes.causes[attributes.causes.length - 1]
17+
: errorMessage;
1518

1619
return {
1720
title: errorTitle,

x-pack/plugins/translations/translations/ja-JP.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9505,8 +9505,6 @@
95059505
"xpack.indexLifecycleMgmt.editPolicy.saveAsNewPolicyMessage": "新規ポリシーとして保存します",
95069506
"xpack.indexLifecycleMgmt.editPolicy.saveButton": "ポリシーを保存",
95079507
"xpack.indexLifecycleMgmt.editPolicy.saveErrorMessage": "ライフサイクルポリシー {lifecycleName} の保存中にエラーが発生しました",
9508-
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotCalloutBody": "検索可能なスナップショットがホットフェーズで有効な場合には、強制、マージ、縮小、凍結、コールドフェーズの検索可能なスナップショットは許可されません。",
9509-
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotDisabledCalloutBody": "ホットフェーズで構成されているときには、コールドフェーズで検索可能なスナップショットを作成できません。",
95109508
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldDescription": "選択したリポジトリで管理されたインデックスのスナップショットを作成し、検索可能なスナップショットとしてマウントします。{learnMoreLink}。",
95119509
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldLabel": "検索可能なスナップショットリポジドリ",
95129510
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldTitle": "検索可能スナップショット",

x-pack/plugins/translations/translations/zh-CN.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9529,8 +9529,6 @@
95299529
"xpack.indexLifecycleMgmt.editPolicy.saveAsNewPolicyMessage": "另存为新策略",
95309530
"xpack.indexLifecycleMgmt.editPolicy.saveButton": "保存策略",
95319531
"xpack.indexLifecycleMgmt.editPolicy.saveErrorMessage": "保存生命周期策略 {lifecycleName} 时出错",
9532-
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotCalloutBody": "在热阶段启用可搜索快照时,不允许强制合并、缩小、冻结可搜索快照以及将其置入冷阶段。",
9533-
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotDisabledCalloutBody": "无法在冷阶段创建在热阶段配置的可搜索快照。",
95349532
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldDescription": "在所选存储库中拍取受管索引的快照,并将其安装为可搜索快照。{learnMoreLink}。",
95359533
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldLabel": "可搜索快照存储库",
95369534
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldTitle": "可搜索快照",

0 commit comments

Comments
 (0)