Skip to content

Commit

Permalink
[ILM] Add "wait for snapshot" text field to edit policy form (Delete …
Browse files Browse the repository at this point in the history
…phase)
  • Loading branch information
yuliacech committed Jun 8, 2020
1 parent 09eaa1c commit dbdf8e9
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export const PHASE_PRIMARY_SHARD_COUNT: string = 'selectedPrimaryShardCount';
export const PHASE_REPLICA_COUNT: string = 'selectedReplicaCount';
export const PHASE_INDEX_PRIORITY: string = 'phaseIndexPriority';

export const PHASE_WAIT_FOR_SNAPSHOT_POLICY = 'waitForSnapshotPolicy';

export const PHASE_ATTRIBUTES_THAT_ARE_NUMBERS_VALIDATE: string[] = [
PHASE_ROLLOVER_MINIMUM_AGE,
PHASE_FORCE_MERGE_SEGMENTS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
import React, { PureComponent, Fragment } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiDescribedFormGroup, EuiSwitch } from '@elastic/eui';
import {
EuiDescribedFormGroup,
EuiSwitch,
EuiFieldText,
EuiTextColor,
EuiFormRow,
} from '@elastic/eui';

import { PHASE_DELETE, PHASE_ENABLED } from '../../../../constants';
import { ActiveBadge, PhaseErrorMessage } from '../../../components';
import { PHASE_DELETE, PHASE_ENABLED, PHASE_WAIT_FOR_SNAPSHOT_POLICY } from '../../../../constants';
import { ActiveBadge, LearnMoreLink, OptionalLabel, PhaseErrorMessage } from '../../../components';
import { MinAgeInput } from '../min_age_input';

export class DeletePhase extends PureComponent {
Expand Down Expand Up @@ -85,6 +91,48 @@ export class DeletePhase extends PureComponent {
<div />
)}
</EuiDescribedFormGroup>
{phaseData[PHASE_ENABLED] ? (
<EuiDescribedFormGroup
title={
<h3>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.deletePhase.waitForSnapshotTitle"
defaultMessage="Wait for snapshot policy"
/>
</h3>
}
description={
<EuiTextColor color="subdued">
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.deletePhase.waitForSnapshotDescription"
defaultMessage="Specify a snapshot policy to be executed before the deletion of the index. This ensures that a snapshot of the deleted index is available."
/>{' '}
<LearnMoreLink docPath="ilm-wait-for-snapshot.html" />
</EuiTextColor>
}
titleSize="xs"
fullWidth
>
<EuiFormRow
id="deletePhaseWaitForSnapshot"
label={
<Fragment>
<FormattedMessage
id="xpack.indexLifecycleMgmt.editPolicy.deletePhase.waitForSnapshotLabel"
defaultMessage="Snapshot policy name"
/>
<OptionalLabel />
</Fragment>
}
>
<EuiFieldText
data-test-subj="waitForSnapshotField"
value={phaseData[PHASE_WAIT_FOR_SNAPSHOT_POLICY]}
onChange={(e) => setPhaseData(PHASE_WAIT_FOR_SNAPSHOT_POLICY, e.target.value)}
/>
</EuiFormRow>
</EuiDescribedFormGroup>
) : null}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

export declare const defaultDeletePhase: any;
export declare const defaultColdPhase: any;
export declare const defaultWarmPhase: any;
export declare const defaultHotPhase: any;
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
PHASE_FREEZE_ENABLED,
PHASE_INDEX_PRIORITY,
PHASE_ROLLOVER_MAX_DOCUMENTS,
PHASE_WAIT_FOR_SNAPSHOT_POLICY,
} from '../../constants';

import { filterItems, sortTable } from '../../services';
Expand Down Expand Up @@ -194,6 +195,9 @@ const phaseFromES = (phase, phaseName, defaultEmptyPolicy) => {
if (actions.set_priority) {
policy[PHASE_INDEX_PRIORITY] = actions.set_priority.priority;
}
if (actions.wait_for_snapshot) {
policy[PHASE_WAIT_FOR_SNAPSHOT_POLICY] = actions.wait_for_snapshot.policy;
}
}
return policy;
};
Expand Down Expand Up @@ -308,5 +312,13 @@ export const phaseToES = (phase, originalEsPhase) => {
priority: phase[PHASE_INDEX_PRIORITY],
};
}

if (phase[PHASE_WAIT_FOR_SNAPSHOT_POLICY]) {
esPhase.actions.wait_for_snapshot = {
policy: phase[PHASE_WAIT_FOR_SNAPSHOT_POLICY],
};
} else {
delete esPhase.actions.wait_for_snapshot;
}
return esPhase;
};

0 comments on commit dbdf8e9

Please sign in to comment.