-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[ILM] Add support for frozen phase in UI #75968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
469e5bb
ILM public side changes to support frozen phase
jloleysens 19afe82
added "frozen" to the server side schema
jloleysens 9ff7eaa
add frozen phases component
jloleysens e7dcc64
fix i18n and update jest tests
jloleysens 5149dd2
Merge branch 'master' into ilm/add-frozen-phase
elasticmachine 067d25a
Merge branch 'master' into ilm/add-frozen-phase
elasticmachine 0935f6b
Slight restructuring to phase types and fix copy paste issues.
jloleysens c366c5e
fix hot phase type and remove type constraint from error messages
jloleysens dc2b0d1
update validation logic
jloleysens a087b04
Merge branch 'master' into ilm/add-frozen-phase
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...ns/index_lifecycle_management/__jest__/__snapshots__/extend_index_management.test.js.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
210 changes: 210 additions & 0 deletions
210
...ndex_lifecycle_management/public/application/sections/edit_policy/phases/frozen_phase.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,210 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import React, { PureComponent, Fragment } from 'react'; | ||
| import { FormattedMessage } from '@kbn/i18n/react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
|
|
||
| import { | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiSpacer, | ||
| EuiFieldNumber, | ||
| EuiDescribedFormGroup, | ||
| EuiSwitch, | ||
| EuiTextColor, | ||
| } from '@elastic/eui'; | ||
|
|
||
| import { FrozenPhase as FrozenPhaseInterface, Phases } from '../../../services/policies/types'; | ||
| import { PhaseValidationErrors } from '../../../services/policies/policy_validation'; | ||
|
|
||
| import { | ||
| LearnMoreLink, | ||
| ActiveBadge, | ||
| PhaseErrorMessage, | ||
| OptionalLabel, | ||
| ErrableFormRow, | ||
| MinAgeInput, | ||
| NodeAllocation, | ||
| SetPriorityInput, | ||
| } from '../components'; | ||
|
|
||
| const freezeLabel = i18n.translate('xpack.indexLifecycleMgmt.frozenPhase.freezeIndexLabel', { | ||
| defaultMessage: 'Freeze index', | ||
| }); | ||
|
|
||
| const frozenProperty: keyof Phases = 'frozen'; | ||
| const phaseProperty = (propertyName: keyof FrozenPhaseInterface) => propertyName; | ||
|
|
||
| interface Props { | ||
| setPhaseData: (key: keyof FrozenPhaseInterface & string, value: string | boolean) => void; | ||
| phaseData: FrozenPhaseInterface; | ||
| isShowingErrors: boolean; | ||
| errors?: PhaseValidationErrors<FrozenPhaseInterface>; | ||
| hotPhaseRolloverEnabled: boolean; | ||
| } | ||
| export class FrozenPhase extends PureComponent<Props> { | ||
| render() { | ||
| const { | ||
| setPhaseData, | ||
| phaseData, | ||
| errors, | ||
| isShowingErrors, | ||
| hotPhaseRolloverEnabled, | ||
| } = this.props; | ||
|
|
||
| return ( | ||
| <div id="frozenPhaseContent" aria-live="polite" role="region"> | ||
| <EuiDescribedFormGroup | ||
| title={ | ||
| <div> | ||
| <h2 className="eui-displayInlineBlock eui-alignMiddle"> | ||
| <FormattedMessage | ||
| id="xpack.indexLifecycleMgmt.editPolicy.frozenPhase.frozenPhaseLabel" | ||
| defaultMessage="Frozen phase" | ||
| /> | ||
| </h2>{' '} | ||
| {phaseData.phaseEnabled && !isShowingErrors ? <ActiveBadge /> : null} | ||
| <PhaseErrorMessage isShowingErrors={isShowingErrors} /> | ||
| </div> | ||
| } | ||
| titleSize="s" | ||
| description={ | ||
| <Fragment> | ||
| <p> | ||
| <FormattedMessage | ||
| id="xpack.indexLifecycleMgmt.editPolicy.frozenPhase.frozenPhaseDescriptionText" | ||
| defaultMessage="You are querying your index very infrequently, so you can allocate shards | ||
| on the least performant hardware. | ||
| Because your queries are slower, you can reduce the number of replicas." | ||
| /> | ||
| </p> | ||
| <EuiSwitch | ||
| data-test-subj="enablePhaseSwitch-frozen" | ||
| label={ | ||
| <FormattedMessage | ||
| id="xpack.indexLifecycleMgmt.editPolicy.frozenPhase.activateWarmPhaseSwitchLabel" | ||
| defaultMessage="Activate frozen phase" | ||
| /> | ||
| } | ||
| id={`${frozenProperty}-${phaseProperty('phaseEnabled')}`} | ||
| checked={phaseData.phaseEnabled} | ||
| onChange={(e) => { | ||
| setPhaseData(phaseProperty('phaseEnabled'), e.target.checked); | ||
| }} | ||
| aria-controls="frozenPhaseContent" | ||
| /> | ||
| </Fragment> | ||
| } | ||
| fullWidth | ||
| > | ||
| <Fragment> | ||
| {phaseData.phaseEnabled ? ( | ||
| <Fragment> | ||
| <MinAgeInput<FrozenPhaseInterface> | ||
| errors={errors} | ||
| phaseData={phaseData} | ||
| phase={frozenProperty} | ||
| isShowingErrors={isShowingErrors} | ||
| setPhaseData={setPhaseData} | ||
| rolloverEnabled={hotPhaseRolloverEnabled} | ||
| /> | ||
| <EuiSpacer /> | ||
|
|
||
| <NodeAllocation<FrozenPhaseInterface> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar here, the props generics don't include frozen phase, but type check is not showing it. |
||
| phase={frozenProperty} | ||
| setPhaseData={setPhaseData} | ||
| errors={errors} | ||
| phaseData={phaseData} | ||
| isShowingErrors={isShowingErrors} | ||
| /> | ||
|
|
||
| <EuiFlexGroup> | ||
| <EuiFlexItem grow={false} style={{ maxWidth: 188 }}> | ||
| <ErrableFormRow | ||
| id={`${frozenProperty}-${phaseProperty('freezeEnabled')}`} | ||
| label={ | ||
| <Fragment> | ||
| <FormattedMessage | ||
| id="xpack.indexLifecycleMgmt.frozenPhase.numberOfReplicasLabel" | ||
| defaultMessage="Number of replicas" | ||
| /> | ||
| <OptionalLabel /> | ||
| </Fragment> | ||
| } | ||
| isShowingErrors={isShowingErrors} | ||
| errors={errors?.freezeEnabled} | ||
| helpText={i18n.translate( | ||
| 'xpack.indexLifecycleMgmt.frozenPhase.replicaCountHelpText', | ||
| { | ||
| defaultMessage: 'By default, the number of replicas remains the same.', | ||
| } | ||
| )} | ||
| > | ||
| <EuiFieldNumber | ||
| id={`${frozenProperty}-${phaseProperty('selectedReplicaCount')}`} | ||
| value={phaseData.selectedReplicaCount} | ||
| onChange={(e) => { | ||
| setPhaseData(phaseProperty('selectedReplicaCount'), e.target.value); | ||
| }} | ||
| min={0} | ||
| /> | ||
| </ErrableFormRow> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </Fragment> | ||
| ) : ( | ||
| <div /> | ||
| )} | ||
| </Fragment> | ||
| </EuiDescribedFormGroup> | ||
| {phaseData.phaseEnabled ? ( | ||
| <Fragment> | ||
| <EuiDescribedFormGroup | ||
| title={ | ||
| <h3> | ||
| <FormattedMessage | ||
| id="xpack.indexLifecycleMgmt.editPolicy.frozenPhase.freezeText" | ||
| defaultMessage="Freeze" | ||
| /> | ||
| </h3> | ||
| } | ||
| description={ | ||
| <EuiTextColor color="subdued"> | ||
| <FormattedMessage | ||
| id="xpack.indexLifecycleMgmt.editPolicy.frozenPhase.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.freezeEnabled} | ||
| onChange={(e) => { | ||
| setPhaseData(phaseProperty('freezeEnabled'), e.target.checked); | ||
| }} | ||
| label={freezeLabel} | ||
| aria-label={freezeLabel} | ||
| /> | ||
| </EuiDescribedFormGroup> | ||
| <SetPriorityInput<FrozenPhaseInterface> | ||
| errors={errors} | ||
| phaseData={phaseData} | ||
| phase={frozenProperty} | ||
| isShowingErrors={isShowingErrors} | ||
| setPhaseData={setPhaseData} | ||
| /> | ||
| </Fragment> | ||
| ) : null} | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MinAgeInput's props are currently typed to accept warm, cold and delete phases. I'm not sure why the type check is not picking it up, but it might be good to add frozen phase to props generics.