adding freeze action to ILM UI (#28572) (#28619)

* adding freeze action to ILM UI

* updating frozen indices description

* copy edits

* fixing issue with disabling freeze action

* removing unneeded Fragment
This commit is contained in:
Bill McConaghy 2019-01-14 09:16:27 -05:00 committed by GitHub
parent ab51c120a6
commit 9ceccc2d94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 173 additions and 117 deletions

View file

@ -15,6 +15,8 @@ import {
EuiFieldNumber,
EuiDescribedFormGroup,
EuiButton,
EuiSwitch,
EuiTextColor,
} from '@elastic/eui';
import {
PHASE_COLD,
@ -24,10 +26,11 @@ import {
PHASE_ROLLOVER_MINIMUM_AGE_UNITS,
PHASE_NODE_ATTRS,
PHASE_REPLICA_COUNT,
PHASE_FREEZE_ENABLED
} from '../../../../store/constants';
import { ErrableFormRow } from '../../form_errors';
import { MinAgeInput } from '../min_age_input';
import { ActiveBadge, PhaseErrorMessage, OptionalLabel } from '../../../components';
import { LearnMoreLink, ActiveBadge, PhaseErrorMessage, OptionalLabel } from '../../../components';
import { NodeAllocation } from '../node_allocation';
class ColdPhaseUi extends PureComponent {
@ -57,123 +60,163 @@ class ColdPhaseUi extends PureComponent {
intl,
hotPhaseRolloverEnabled
} = this.props;
const freezeLabel = intl.formatMessage({
id: 'xpack.indexLifecycleMgmt.coldPhase.freezeIndexLabel',
defaultMessage: 'Freeze index',
});
return (
<EuiDescribedFormGroup
title={
<div>
<span className="eui-displayInlineBlock eui-alignMiddle">
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.coldPhase.coldPhaseLabel"
defaultMessage="Cold phase"
/>
</span>{' '}
{phaseData[PHASE_ENABLED] && !isShowingErrors ? <ActiveBadge /> : null}
<PhaseErrorMessage isShowingErrors={isShowingErrors} />
</div>
}
titleSize="s"
description={
<Fragment>
<p>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.coldPhase.coldPhaseDescriptionText"
defaultMessage="You are querying your index less frequently, so you can allocate shards
<Fragment>
<EuiDescribedFormGroup
title={
<div>
<span className="eui-displayInlineBlock eui-alignMiddle">
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.coldPhase.coldPhaseLabel"
defaultMessage="Cold phase"
/>
</span>{' '}
{phaseData[PHASE_ENABLED] && !isShowingErrors ? <ActiveBadge /> : null}
<PhaseErrorMessage isShowingErrors={isShowingErrors} />
</div>
}
titleSize="s"
description={
<Fragment>
<p>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.coldPhase.coldPhaseDescriptionText"
defaultMessage="You are querying your index less frequently, so you can allocate shards
on significantly less performant hardware.
Because your queries are slower, you can reduce the number of replicas."
/>
</p>
{phaseData[PHASE_ENABLED] ? (
<EuiButton
color="danger"
onClick={async () => {
await setPhaseData(PHASE_ENABLED, false);
}}
aria-controls="coldPhaseContent"
>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.coldhase.deactivateColdPhaseButton"
defaultMessage="Deactivate cold phase"
/>
</EuiButton>
) : (
<EuiButton
data-test-subj="activatePhaseButton-cold"
onClick={async () => {
await setPhaseData(PHASE_ENABLED, true);
}}
aria-controls="coldPhaseContent"
>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.coldPhase.activateColdPhaseButton"
defaultMessage="Activate cold phase"
/>
</EuiButton>
)}
</Fragment>
}
fullWidth
>
<div id="coldPhaseContent" aria-live="polite" role="region">
{phaseData[PHASE_ENABLED] ? (
<Fragment>
<MinAgeInput
errors={errors}
phaseData={phaseData}
phase={PHASE_COLD}
isShowingErrors={isShowingErrors}
setPhaseData={setPhaseData}
rolloverEnabled={hotPhaseRolloverEnabled}
/>
<EuiSpacer />
<NodeAllocation
phase={PHASE_COLD}
setPhaseData={setPhaseData}
showNodeDetailsFlyout={showNodeDetailsFlyout}
errors={errors}
phaseData={phaseData}
isShowingErrors={isShowingErrors}
/>
<EuiFlexGroup>
<EuiFlexItem grow={false} style={{ maxWidth: 188 }}>
<ErrableFormRow
id={`${PHASE_COLD}-${PHASE_REPLICA_COUNT}`}
label={
<Fragment>
<FormattedMessage
id="xpack.indexLifecycleMgmt.coldPhase.numberOfReplicasLabel"
defaultMessage="Number of replicas"
/>
<OptionalLabel />
</Fragment>
}
errorKey={PHASE_REPLICA_COUNT}
isShowingErrors={isShowingErrors}
errors={errors}
helpText={
intl.formatMessage({
id: 'xpack.indexLifecycleMgmt.coldPhase.replicaCountHelpText',
defaultMessage: 'By default, the number of replicas remains the same.'
})
}
>
<EuiFieldNumber
id={`${PHASE_COLD}-${PHASE_REPLICA_COUNT}`}
value={phaseData[PHASE_REPLICA_COUNT]}
onChange={async e => {
await setPhaseData(PHASE_REPLICA_COUNT, e.target.value);
}}
min={0}
/>
</ErrableFormRow>
</EuiFlexItem>
</EuiFlexGroup>
</p>
{phaseData[PHASE_ENABLED] ? (
<EuiButton
color="danger"
onClick={async () => {
await setPhaseData(PHASE_ENABLED, false);
}}
aria-controls="coldPhaseContent"
>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.coldhase.deactivateColdPhaseButton"
defaultMessage="Deactivate cold phase"
/>
</EuiButton>
) : (
<EuiButton
data-test-subj="activatePhaseButton-cold"
onClick={async () => {
await setPhaseData(PHASE_ENABLED, true);
}}
aria-controls="coldPhaseContent"
>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.coldPhase.activateColdPhaseButton"
defaultMessage="Activate cold phase"
/>
</EuiButton>
)}
</Fragment>
) : <div />}
</div>
</EuiDescribedFormGroup>
}
fullWidth
>
<div id="coldPhaseContent" aria-live="polite" role="region">
{phaseData[PHASE_ENABLED] ? (
<Fragment>
<MinAgeInput
errors={errors}
phaseData={phaseData}
phase={PHASE_COLD}
isShowingErrors={isShowingErrors}
setPhaseData={setPhaseData}
rolloverEnabled={hotPhaseRolloverEnabled}
/>
<EuiSpacer />
<NodeAllocation
phase={PHASE_COLD}
setPhaseData={setPhaseData}
showNodeDetailsFlyout={showNodeDetailsFlyout}
errors={errors}
phaseData={phaseData}
isShowingErrors={isShowingErrors}
/>
<EuiFlexGroup>
<EuiFlexItem grow={false} style={{ maxWidth: 188 }}>
<ErrableFormRow
id={`${PHASE_COLD}-${PHASE_REPLICA_COUNT}`}
label={
<Fragment>
<FormattedMessage
id="xpack.indexLifecycleMgmt.coldPhase.numberOfReplicasLabel"
defaultMessage="Number of replicas"
/>
<OptionalLabel />
</Fragment>
}
errorKey={PHASE_REPLICA_COUNT}
isShowingErrors={isShowingErrors}
errors={errors}
helpText={
intl.formatMessage({
id: 'xpack.indexLifecycleMgmt.coldPhase.replicaCountHelpText',
defaultMessage: 'By default, the number of replicas remains the same.'
})
}
>
<EuiFieldNumber
id={`${PHASE_COLD}-${PHASE_REPLICA_COUNT}`}
value={phaseData[PHASE_REPLICA_COUNT]}
onChange={async e => {
await setPhaseData(PHASE_REPLICA_COUNT, e.target.value);
}}
min={0}
/>
</ErrableFormRow>
</EuiFlexItem>
</EuiFlexGroup>
</Fragment>
) : <div />}
</div>
</EuiDescribedFormGroup>
{phaseData[PHASE_ENABLED] ? (
<EuiDescribedFormGroup
title={
<p>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.coldPhase.freezeText"
defaultMessage="Freeze"
/>
</p>
}
description={
<EuiTextColor color="subdued">
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.coldPhase.freezeIndexExplanationText"
defaultMessage="A frozen index has little overhead on the cluster and is blocked for write operations.
You can search a frozen index, but expect queries to be slower."
/>{' '}
<LearnMoreLink docPath="frozen-indices.html" />
</EuiTextColor>
}
fullWidth
titleSize="xs"
>
<EuiSwitch
data-test-subj="freezeSwitch"
checked={phaseData[PHASE_FREEZE_ENABLED]}
onChange={async e => {
await setPhaseData(PHASE_FREEZE_ENABLED, e.target.checked);
}}
label={freezeLabel}
aria-label={freezeLabel}
/>
</EuiDescribedFormGroup>
) : null }
</Fragment>
);
}
}

View file

@ -102,8 +102,8 @@ class WarmPhaseUi extends PureComponent {
<p>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.warmPhase.warmPhaseDescriptionMessage"
defaultMessage="You are still querying your index, but it is read-only, and you are no longer
updating it. You can allocate shards to less performant hardware.
defaultMessage="You are still querying your index, but it is read-only.
You can allocate shards to less performant hardware.
For faster searches, you can reduce the number of shards and force merge segments."
/>
</p>

View file

@ -27,6 +27,7 @@ export const PHASE_ROLLOVER_MINIMUM_AGE_UNITS = 'selectedMinimumAgeUnits';
export const PHASE_FORCE_MERGE_SEGMENTS = 'selectedForceMergeSegments';
export const PHASE_FORCE_MERGE_ENABLED = 'forceMergeEnabled';
export const PHASE_FREEZE_ENABLED = 'freezeEnabled';
export const PHASE_SHRINK_ENABLED = 'shrinkEnabled';

View file

@ -10,6 +10,7 @@ import {
PHASE_REPLICA_COUNT,
PHASE_ROLLOVER_MINIMUM_AGE_UNITS,
PHASE_ROLLOVER_ALIAS,
PHASE_FREEZE_ENABLED,
} from '../constants';
export const defaultColdPhase = {
@ -18,5 +19,6 @@ export const defaultColdPhase = {
[PHASE_ROLLOVER_MINIMUM_AGE]: '',
[PHASE_ROLLOVER_MINIMUM_AGE_UNITS]: 'd',
[PHASE_NODE_ATTRS]: '',
[PHASE_REPLICA_COUNT]: ''
[PHASE_REPLICA_COUNT]: '',
[PHASE_FREEZE_ENABLED]: false
};

View file

@ -35,7 +35,8 @@ import {
PHASE_ATTRIBUTES_THAT_ARE_NUMBERS,
MAX_SIZE_TYPE_DOCUMENT,
WARM_PHASE_ON_ROLLOVER,
PHASE_SHRINK_ENABLED
PHASE_SHRINK_ENABLED,
PHASE_FREEZE_ENABLED
} from '../constants';
import { filterItems, sortTable } from '../../services';
@ -194,6 +195,9 @@ export const phaseFromES = (phase, phaseName, defaultPolicy) => {
if (actions.shrink) {
policy[PHASE_PRIMARY_SHARD_COUNT] = actions.shrink.number_of_shards;
}
if (actions.freeze) {
policy[PHASE_FREEZE_ENABLED] = true;
}
}
return policy;
};
@ -276,5 +280,11 @@ export const phaseToES = (phase, originalEsPhase) => {
} else {
delete esPhase.actions.shrink;
}
if (phase[PHASE_FREEZE_ENABLED]) {
esPhase.actions.freeze = {};
} else {
delete esPhase.actions.freeze;
}
return esPhase;
};