Skip to content

Commit

Permalink
[7.11] [ILM] Fix replicas not showing (elastic#92782) (elastic#92871)
Browse files Browse the repository at this point in the history
* [ILM] Fix replicas not showing  (elastic#92782)

* 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

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/cold_phase/cold_phase.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/warm_phase/warm_phase.tsx

* added missing helpers

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
2 people authored and legrego committed Mar 1, 2021
1 parent 16d1bb1 commit 002358a
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 90 deletions.
11 changes: 11 additions & 0 deletions docs/migration/migrate_7_11.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,15 @@ will fail and Kibana will not start.

*via https://github.com/elastic/kibana/pull/80766[#80766]*

[discrete]
[[glibc_212_unsupported]]
=== Dropped support for glibc 1.12

*Details:* {kib} 7.11.0 upgrades the Node.js runtime to version `14.16.0`. This updated runtime requires glibc `2.16`,
wich drops support for glibc `2.12`-based operating systems.

*Impact*: Supported versions of {kib} will not be impacted. Users will no longer be able to run {kib} on older operating systems wich require glibc `2.12` (example: CentOS 6). Please see our https://www.elastic.co/support/matrix[support matrix] for a list of currently supported operating systems.

*via https://github.com/elastic/kibana/pull/83425[#83425]*

// end::notable-breaking-changes[]
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,21 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
const setFreeze = createFormToggleAction('freezeSwitch');
const freezeExists = () => exists('freezeSwitch');

const setReadonly = (phase: Phases) => async (value: boolean) => {
await createFormToggleAction(`${phase}-readonlySwitch`)(value);
const createReadonlyActions = (phase: Phases) => {
const toggleSelector = `${phase}-readonlySwitch`;
return {
readonlyExists: () => exists(toggleSelector),
toggleReadonly: createFormToggleAction(toggleSelector),
};
};

const createSearchableSnapshotActions = (phase: Phases) => {
const fieldSelector = `searchableSnapshotField-${phase}`;
const licenseCalloutSelector = `${fieldSelector}.searchableSnapshotDisabledDueToLicense`;
const rolloverCalloutSelector = `${fieldSelector}.searchableSnapshotFieldsNoRolloverCallout`;
const toggleSelector = `${fieldSelector}.searchableSnapshotToggle`;

const toggleSearchableSnapshot = createFormToggleAction(toggleSelector);
return {
searchableSnapshotDisabledDueToRollover: () => exists(rolloverCalloutSelector),
searchableSnapshotDisabled: () =>
exists(licenseCalloutSelector) && find(licenseCalloutSelector).props().disabled === true,
searchableSnapshotsExists: () => exists(fieldSelector),
Expand Down Expand Up @@ -254,7 +256,7 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
setIndexPriority: setIndexPriority('hot'),
setShrink: setShrink('hot'),
shrinkExists: shrinkExists('hot'),
setReadonly: setReadonly('hot'),
...createReadonlyActions('hot'),
...createSearchableSnapshotActions('hot'),
},
warm: {
Expand All @@ -269,7 +271,7 @@ export const setup = async (arg?: { appServicesContext: Partial<AppServicesConte
setShrink: setShrink('warm'),
shrinkExists: shrinkExists('warm'),
...createForceMergeActions('warm'),
setReadonly: setReadonly('warm'),
...createReadonlyActions('warm'),
setIndexPriority: setIndexPriority('warm'),
},
cold: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('<EditPolicy />', () => {
await actions.hot.setForcemergeSegmentsCount('123');
await actions.hot.setBestCompression(true);
await actions.hot.setShrink('2');
await actions.hot.setReadonly(true);
await actions.hot.toggleReadonly(true);
await actions.hot.setIndexPriority('123');

await actions.savePolicy();
Expand Down Expand Up @@ -275,7 +275,7 @@ describe('<EditPolicy />', () => {
await actions.warm.toggleForceMerge(true);
await actions.warm.setForcemergeSegmentsCount('123');
await actions.warm.setBestCompression(true);
await actions.warm.setReadonly(true);
await actions.warm.toggleReadonly(true);
await actions.warm.setIndexPriority('123');
await actions.savePolicy();
const latestRequest = server.requests[server.requests.length - 1];
Expand Down Expand Up @@ -426,6 +426,7 @@ describe('<EditPolicy />', () => {
await actions.cold.setMinAgeUnits('s');
await actions.cold.setDataAllocation('node_attrs');
await actions.cold.setSelectedNodeAttribute('test:123');
await actions.cold.setSearchableSnapshot('my-repo');
await actions.cold.setReplicas('123');
await actions.cold.setFreeze(true);
await actions.cold.setIndexPriority('123');
Expand All @@ -447,6 +448,9 @@ describe('<EditPolicy />', () => {
},
},
"freeze": Object {},
"searchable_snapshot": Object {
"snapshot_repository": "my-repo",
},
"set_priority": Object {
"priority": 123,
},
Expand All @@ -469,19 +473,6 @@ describe('<EditPolicy />', () => {
}
`);
});

// Setting searchable snapshot field disables setting replicas so we test this separately
test('setting searchable snapshot', async () => {
const { actions } = testBed;
await actions.cold.enable(true);
await actions.cold.setSearchableSnapshot('my-repo');
await actions.savePolicy();
const latestRequest2 = server.requests[server.requests.length - 1];
const entirePolicy2 = JSON.parse(JSON.parse(latestRequest2.requestBody).body);
expect(entirePolicy2.phases.cold.actions.searchable_snapshot.snapshot_repository).toEqual(
'my-repo'
);
});
});
});

Expand Down Expand Up @@ -888,14 +879,15 @@ describe('<EditPolicy />', () => {
const { component } = testBed;
component.update();
});
test('hiding and disabling searchable snapshot field', async () => {
test('hides fields in hot phase', async () => {
const { actions } = testBed;
await actions.hot.toggleDefaultRollover(false);
await actions.hot.toggleRollover(false);
await actions.cold.enable(true);

expect(actions.hot.forceMergeFieldExists()).toBeFalsy();
expect(actions.hot.shrinkExists()).toBeFalsy();
expect(actions.hot.searchableSnapshotsExists()).toBeFalsy();
expect(actions.cold.searchableSnapshotDisabledDueToRollover()).toBeTruthy();
expect(actions.hot.readonlyExists()).toBeFalsy();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ export const ColdPhase: FunctionComponent = () => {
const { isUsingSearchableSnapshotInHotPhase } = useConfigurationIssues();

const [formData] = useFormData({
watch: [formFieldPaths.enabled, formFieldPaths.searchableSnapshot],
watch: [formFieldPaths.enabled],
});

const enabled = get(formData, formFieldPaths.enabled);
const showReplicasField = get(formData, formFieldPaths.searchableSnapshot) == null;
const enabled = !!get(formData, formFieldPaths.enabled);

return (
<div id="coldPhaseContent" aria-live="polite" role="region">
Expand Down Expand Up @@ -118,49 +117,45 @@ export const ColdPhase: FunctionComponent = () => {
)}
paddingSize="m"
>
{
/* Replicas section */
showReplicasField && (
<DescribedFormRow
title={
<h3>
{i18n.translate('xpack.indexLifecycleMgmt.coldPhase.replicasTitle', {
defaultMessage: 'Replicas',
})}
</h3>
}
description={i18n.translate(
'xpack.indexLifecycleMgmt.coldPhase.numberOfReplicasDescription',
{
defaultMessage:
'Set the number of replicas. Remains the same as the previous phase by default.',
}
)}
switchProps={{
'data-test-subj': 'cold-setReplicasSwitch',
label: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.coldPhase.numberOfReplicas.switchLabel',
{ defaultMessage: 'Set replicas' }
),
initialValue:
policy.phases.cold?.actions?.allocate?.number_of_replicas != null,
}}
fullWidth
>
<UseField
path="phases.cold.actions.allocate.number_of_replicas"
component={NumericField}
componentProps={{
fullWidth: false,
euiFieldProps: {
'data-test-subj': `${coldProperty}-selectedReplicaCount`,
min: 0,
},
}}
/>
</DescribedFormRow>
)
}
{/* Replicas section */}

<DescribedFormRow
title={
<h3>
{i18n.translate('xpack.indexLifecycleMgmt.coldPhase.replicasTitle', {
defaultMessage: 'Replicas',
})}
</h3>
}
description={i18n.translate(
'xpack.indexLifecycleMgmt.coldPhase.numberOfReplicasDescription',
{
defaultMessage:
'Set the number of replicas. Remains the same as the previous phase by default.',
}
)}
switchProps={{
'data-test-subj': 'cold-setReplicasSwitch',
label: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.coldPhase.numberOfReplicas.switchLabel',
{ defaultMessage: 'Set replicas' }
),
initialValue: policy.phases.cold?.actions?.allocate?.number_of_replicas != null,
}}
fullWidth
>
<UseField
path="phases.cold.actions.allocate.number_of_replicas"
component={NumericField}
componentProps={{
fullWidth: false,
euiFieldProps: {
'data-test-subj': `${coldProperty}-selectedReplicaCount`,
min: 0,
},
}}
/>
</DescribedFormRow>

{/* Freeze section */}
{!isUsingSearchableSnapshotInHotPhase && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
services: { cloud },
} = useKibana();
const { getUrlForApp, policy, license, isNewPolicy } = useEditPolicyContext();
const { isUsingSearchableSnapshotInHotPhase, isUsingRollover } = useConfigurationIssues();
const { isUsingSearchableSnapshotInHotPhase } = useConfigurationIssues();

const searchableSnapshotPath = `phases.${phase}.actions.searchable_snapshot.snapshot_repository`;

Expand All @@ -63,10 +63,8 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
const isColdPhase = phase === 'cold';
const isDisabledDueToLicense = !license.canUseSearchableSnapshot();
const isDisabledInColdDueToHotPhase = isColdPhase && isUsingSearchableSnapshotInHotPhase;
const isDisabledInColdDueToRollover = isColdPhase && !isUsingRollover;

const isDisabled =
isDisabledDueToLicense || isDisabledInColdDueToHotPhase || isDisabledInColdDueToRollover;
const isDisabled = isDisabledDueToLicense || isDisabledInColdDueToHotPhase;

const [isFieldToggleChecked, setIsFieldToggleChecked] = useState(() =>
Boolean(
Expand Down Expand Up @@ -294,20 +292,6 @@ export const SearchableSnapshotField: FunctionComponent<Props> = ({ phase }) =>
)}
/>
);
} else if (isDisabledInColdDueToRollover) {
infoCallout = (
<EuiCallOut
size="s"
data-test-subj="searchableSnapshotFieldsNoRolloverCallout"
title={i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotNoRolloverCalloutBody',
{
defaultMessage:
'Cannot create a searchable snapshot when rollover is disabled in the hot phase.',
}
)}
/>
);
}

return infoCallout ? (
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -9760,7 +9760,6 @@
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldTitle": "検索可能スナップショット",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotLicenseCalloutBody": "検索可能なスナップショットを作成するには、エンタープライズライセンスが必要です。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotLicenseCalloutTitle": "エンタープライズライセンスが必要です",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotNoRolloverCalloutBody": "ロールオーバーがホットフェーズで無効な時には、検索可能なスナップショットを作成できません。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotRepoRequiredError": "スナップショットリポジトリ名が必要です。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotsToggleLabel": "検索可能スナップショットを作成",
"xpack.indexLifecycleMgmt.editPolicy.showPolicyJsonButto": "リクエストを表示",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -9784,7 +9784,6 @@
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotFieldTitle": "可搜索快照",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotLicenseCalloutBody": "要创建可搜索快照,需要企业许可证。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotLicenseCalloutTitle": "需要企业许可证",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotNoRolloverCalloutBody": "在热阶段禁用滚动更新后,无法创建可搜索快照。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotRepoRequiredError": "快照存储库名称必填。",
"xpack.indexLifecycleMgmt.editPolicy.searchableSnapshotsToggleLabel": "创建可搜索快照",
"xpack.indexLifecycleMgmt.editPolicy.showPolicyJsonButto": "显示请求",
Expand Down

0 comments on commit 002358a

Please sign in to comment.