Skip to content

Commit

Permalink
[ILM] Add support for allow_write_after_shrink field (elastic#188111)
Browse files Browse the repository at this point in the history
Closes elastic#183776

## Summary

This PR adds support for the `allow_write_after_shrink` field in the
"Shrink" section of the Hot and Warm phase advanced settings.

<img width="933" alt="Screenshot 2024-07-11 at 15 36 30"
src="https://github.com/elastic/kibana/assets/59341489/3a4459d4-2ba3-405f-85f3-9deb6d1c4f35">



https://github.com/elastic/kibana/assets/59341489/1bae2659-dae1-452a-a7ec-5279a70e76f9



### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
ElenaStoeva and elasticmachine authored Jul 16, 2024
1 parent e765833 commit 74db933
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export interface AllocateAction {
export interface ShrinkAction {
number_of_shards?: number;
max_primary_shard_size?: string;
allow_write_after_shrink?: boolean;
}

export interface ForcemergeAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ describe('<EditPolicy /> serialization', () => {
await actions.hot.setForcemergeSegmentsCount('123');
await actions.hot.setBestCompression(true);
await actions.hot.setShrinkCount('2');
await actions.hot.toggleAllowWriteAfterShrink();
await actions.hot.toggleReadonly();
await actions.hot.setIndexPriority('123');

Expand Down Expand Up @@ -226,6 +227,7 @@ describe('<EditPolicy /> serialization', () => {
},
shrink: {
number_of_shards: 2,
allow_write_after_shrink: true,
},
set_priority: {
priority: 123,
Expand Down Expand Up @@ -336,6 +338,7 @@ describe('<EditPolicy /> serialization', () => {
await actions.warm.setSelectedNodeAttribute('test:123');
await actions.warm.setReplicas('123');
await actions.warm.setShrinkCount('123');
await actions.warm.toggleAllowWriteAfterShrink();
await actions.warm.toggleForceMerge();
await actions.warm.setForcemergeSegmentsCount('123');
await actions.warm.setBestCompression(true);
Expand Down Expand Up @@ -366,6 +369,7 @@ describe('<EditPolicy /> serialization', () => {
},
shrink: {
number_of_shards: 123,
allow_write_after_shrink: true,
},
forcemerge: {
max_num_segments: 123,
Expand Down Expand Up @@ -690,6 +694,7 @@ describe('<EditPolicy /> serialization', () => {
await actions.togglePhase('warm');
await actions.warm.setMinAgeValue('11');
await actions.warm.setShrinkSize('100');
await actions.warm.toggleAllowWriteAfterShrink();

await actions.savePolicy();

Expand All @@ -707,6 +712,7 @@ describe('<EditPolicy /> serialization', () => {
max_primary_shard_size: '50gb',
},
shrink: {
allow_write_after_shrink: false,
max_primary_shard_size: '50gb',
},
},
Expand All @@ -718,6 +724,7 @@ describe('<EditPolicy /> serialization', () => {
priority: 50,
},
shrink: {
allow_write_after_shrink: true,
max_primary_shard_size: '100gb',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const createShrinkActions = (testBed: TestBed, phase: Phase) => {
const toggleShrinkSelector = `${phase}-shrinkSwitch`;
const shrinkSizeSelector = `${phase}-primaryShardSize`;
const shrinkCountSelector = `${phase}-primaryShardCount`;
const allowWritesToggleSelector = `${phase}-allowWriteAfterShrink`;

const changeShrinkRadioButton = async (selector: string) => {
await act(async () => {
Expand Down Expand Up @@ -42,5 +43,11 @@ export const createShrinkActions = (testBed: TestBed, phase: Phase) => {
}
await createFormSetValueAction(testBed, shrinkSizeSelector)(value);
},
toggleAllowWriteAfterShrink: async () => {
if (!exists(allowWritesToggleSelector)) {
await form.toggleEuiSwitch(toggleShrinkSelector);
}
await form.toggleEuiSwitch(allowWritesToggleSelector);
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EuiTextColor, EuiRadioGroup, EuiSpacer } from '@elastic/eui';
import React, { FunctionComponent } from 'react';

import { get } from 'lodash';
import { NumericField, useFormData } from '../../../../../../shared_imports';
import { NumericField, ToggleField, useFormData } from '../../../../../../shared_imports';

import { useEditPolicyContext } from '../../../edit_policy_context';
import { UseField, useGlobalFields } from '../../../form';
Expand Down Expand Up @@ -107,6 +107,15 @@ export const ShrinkField: FunctionComponent<Props> = ({ phase }) => {
},
}}
/>
<EuiSpacer />
<UseField
path={`phases.${phase}.actions.shrink.allow_write_after_shrink`}
key={`phases.${phase}.actions.shrink.allow_write_after_shrink`}
component={ToggleField}
euiFieldProps={{
'data-test-subj': `${phase}-allowWriteAfterShrink`,
}}
/>
</>
)}
</DescribedFormRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ const shardSizeField = {
serializer: serializers.stringToNumber,
};

const allowWriteAfterShrinkField = {
label: i18nTexts.editPolicy.allowWriteAfterShrinkLabel,
defaultValue: false,
};

const getPriorityField = (phase: PhaseExceptDelete) => ({
defaultValue: defaultIndexPriority[phase],
label: i18nTexts.editPolicy.indexPriorityFieldLabel,
Expand Down Expand Up @@ -458,6 +463,7 @@ export const getSchema = (isCloudEnabled: boolean): FormSchema => ({
shrink: {
number_of_shards: numberOfShardsField,
max_primary_shard_size: shardSizeField,
allow_write_after_shrink: allowWriteAfterShrinkField,
},
set_priority: {
priority: getPriorityField('hot'),
Expand All @@ -474,6 +480,7 @@ export const getSchema = (isCloudEnabled: boolean): FormSchema => ({
shrink: {
number_of_shards: numberOfShardsField,
max_primary_shard_size: shardSizeField,
allow_write_after_shrink: allowWriteAfterShrinkField,
},
forcemerge: {
max_num_segments: maxNumSegmentsField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export const i18nTexts = {
defaultMessage: 'Configure shard size',
}
),
allowWriteAfterShrinkLabel: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.shrink.allowWritesLabel',
{
defaultMessage: 'Allow writes after shrink',
}
),
rolloverOffsetsHotPhaseTiming: i18n.translate(
'xpack.indexLifecycleMgmt.rollover.rolloverOffsetsPhaseTimingDescription',
{
Expand Down

0 comments on commit 74db933

Please sign in to comment.