Skip to content
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

[ILM] Add "wait for snapshot" policy field to Delete phase #68505

Merged
merged 4 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
};