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

[7.x] Round #1 of removing frozen phase UI and server code (#77877) #77990

Merged
merged 1 commit into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -611,116 +611,6 @@ describe('edit policy', () => {
expect(findTestSubject(rendered, 'defaultAllocationWarning').exists()).toBeTruthy();
});
});
describe('frozen phase', () => {
beforeEach(() => {
server.respondImmediately = true;
http.setupNodeListResponse();
httpRequestsMockHelpers.setNodesDetailsResponse('attribute:true', [
{ nodeId: 'testNodeId', stats: { name: 'testNodeName', host: 'testHost' } },
]);
});
test('should allow 0 for phase timing', async () => {
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
await activatePhase(rendered, 'frozen');
setPhaseAfter(rendered, 'frozen', 0);
save(rendered);
expectedErrorMessages(rendered, []);
});
test('should show positive number required error when trying to save cold phase with -1 for after', async () => {
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
await activatePhase(rendered, 'frozen');
setPhaseAfter(rendered, 'frozen', -1);
save(rendered);
expectedErrorMessages(rendered, [positiveNumberRequiredMessage]);
});
test('should show spinner for node attributes input when loading', async () => {
server.respondImmediately = false;
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
await activatePhase(rendered, 'frozen');
expect(rendered.find('.euiLoadingSpinner').exists()).toBeTruthy();
expect(rendered.find('.euiCallOut--warning').exists()).toBeFalsy();
expect(getNodeAttributeSelect(rendered, 'frozen').exists()).toBeFalsy();
});
test('should show warning instead of node attributes input when none exist', async () => {
http.setupNodeListResponse({
nodesByAttributes: {},
nodesByRoles: { data: ['node1'] },
});
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
await activatePhase(rendered, 'frozen');
expect(rendered.find('.euiLoadingSpinner').exists()).toBeFalsy();
openNodeAttributesSection(rendered, 'frozen');
expect(findTestSubject(rendered, 'noNodeAttributesWarning').exists()).toBeTruthy();
expect(getNodeAttributeSelect(rendered, 'frozen').exists()).toBeFalsy();
});
test('should show node attributes input when attributes exist', async () => {
http.setupNodeListResponse();
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
await activatePhase(rendered, 'frozen');
expect(rendered.find('.euiLoadingSpinner').exists()).toBeFalsy();
openNodeAttributesSection(rendered, 'frozen');
expect(findTestSubject(rendered, 'noNodeAttributesWarning').exists()).toBeFalsy();
const nodeAttributesSelect = getNodeAttributeSelect(rendered, 'frozen');
expect(nodeAttributesSelect.exists()).toBeTruthy();
expect(nodeAttributesSelect.find('option').length).toBe(2);
});
test('should show view node attributes link when attribute selected and show flyout when clicked', async () => {
http.setupNodeListResponse();
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
await activatePhase(rendered, 'frozen');
expect(rendered.find('.euiLoadingSpinner').exists()).toBeFalsy();
openNodeAttributesSection(rendered, 'frozen');
expect(findTestSubject(rendered, 'noNodeAttributesWarning').exists()).toBeFalsy();
const nodeAttributesSelect = getNodeAttributeSelect(rendered, 'frozen');
expect(nodeAttributesSelect.exists()).toBeTruthy();
expect(findTestSubject(rendered, 'frozen-viewNodeDetailsFlyoutButton').exists()).toBeFalsy();
expect(nodeAttributesSelect.find('option').length).toBe(2);
nodeAttributesSelect.simulate('change', { target: { value: 'attribute:true' } });
rendered.update();
const flyoutButton = findTestSubject(rendered, 'frozen-viewNodeDetailsFlyoutButton');
expect(flyoutButton.exists()).toBeTruthy();
await act(async () => {
await flyoutButton.simulate('click');
});
rendered.update();
expect(rendered.find('.euiFlyout').exists()).toBeTruthy();
});
test('should show positive number required error when trying to save with -1 for index priority', async () => {
http.setupNodeListResponse();
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
await activatePhase(rendered, 'frozen');
setPhaseAfter(rendered, 'frozen', 1);
setPhaseIndexPriority(rendered, 'frozen', -1);
save(rendered);
expectedErrorMessages(rendered, [positiveNumberRequiredMessage]);
});
test('should show default allocation warning when no node roles are found', async () => {
http.setupNodeListResponse({
nodesByAttributes: {},
nodesByRoles: {},
});
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
await activatePhase(rendered, 'frozen');
expect(rendered.find('.euiLoadingSpinner').exists()).toBeFalsy();
expect(findTestSubject(rendered, 'defaultAllocationWarning').exists()).toBeTruthy();
});
});
describe('delete phase', () => {
test('should allow 0 for phase timing', async () => {
const rendered = mountWithIntl(component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { Index as IndexInterface } from '../../../index_management/common/types';

export type PhaseWithAllocation = 'warm' | 'cold' | 'frozen';
export type PhaseWithAllocation = 'warm' | 'cold';

export interface SerializedPolicy {
name: string;
Expand All @@ -17,7 +17,6 @@ export interface Phases {
hot?: SerializedHotPhase;
warm?: SerializedWarmPhase;
cold?: SerializedColdPhase;
frozen?: SerializedFrozenPhase;
delete?: SerializedDeletePhase;
}

Expand Down Expand Up @@ -79,17 +78,6 @@ export interface SerializedColdPhase extends SerializedPhase {
};
}

export interface SerializedFrozenPhase extends SerializedPhase {
actions: {
freeze?: {};
allocate?: AllocateAction;
set_priority?: {
priority: number | null;
};
migrate?: { enabled: boolean };
};
}

export interface SerializedDeletePhase extends SerializedPhase {
actions: {
wait_for_snapshot?: {
Expand Down Expand Up @@ -123,7 +111,6 @@ export interface Policy {
hot: HotPhase;
warm: WarmPhase;
cold: ColdPhase;
frozen: FrozenPhase;
delete: DeletePhase;
};
}
Expand Down Expand Up @@ -196,14 +183,6 @@ export interface ColdPhase
freezeEnabled: boolean;
}

export interface FrozenPhase
extends CommonPhaseSettings,
PhaseWithMinAge,
PhaseWithAllocationAction,
PhaseWithIndexPriority {
freezeEnabled: boolean;
}

export interface DeletePhase extends CommonPhaseSettings, PhaseWithMinAge {
waitForSnapshotPolicy: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
DeletePhase,
HotPhase,
WarmPhase,
FrozenPhase,
} from '../../../common/types';

export const defaultNewHotPhase: HotPhase = {
Expand Down Expand Up @@ -52,17 +51,6 @@ export const defaultNewColdPhase: ColdPhase = {
dataTierAllocationType: 'default',
};

export const defaultNewFrozenPhase: FrozenPhase = {
phaseEnabled: false,
selectedMinimumAge: '0',
selectedMinimumAgeUnits: 'd',
selectedNodeAttrs: '',
selectedReplicaCount: '',
freezeEnabled: false,
phaseIndexPriority: '0',
dataTierAllocationType: 'default',
};

export const defaultNewDeletePhase: DeletePhase = {
phaseEnabled: false,
selectedMinimumAge: '0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,38 +86,6 @@ const i18nTexts = {
),
},
},
frozen: {
default: {
input: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.defaultOption.input',
{ defaultMessage: 'Use frozen nodes (recommended)' }
),
helpText: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.defaultOption.helpText',
{ defaultMessage: 'Move data to nodes in the frozen tier.' }
),
},
none: {
inputDisplay: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.noneOption.input',
{ defaultMessage: 'Off' }
),
helpText: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.noneOption.helpText',
{ defaultMessage: 'Do not move data in the frozen phase.' }
),
},
custom: {
inputDisplay: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.customOption.input',
{ defaultMessage: 'Custom' }
),
helpText: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.common.dataTierAllocation.frozen.customOption.helpText',
{ defaultMessage: 'Move data based on node attributes.' }
),
},
},
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ const i18nTexts = {
}
),
},
frozen: {
title: i18n.translate(
'xpack.indexLifecycleMgmt.frozenPhase.dataTier.defaultAllocationNotAvailableTitle',
{ defaultMessage: 'No nodes assigned to the frozen tier' }
),
body: i18n.translate(
'xpack.indexLifecycleMgmt.frozenPhase.dataTier.defaultAllocationNotAvailableBody',
{
defaultMessage:
'Assign at least one node to the frozen tier to use role-based allocation. The policy will fail to complete allocation if there are no frozen nodes.',
}
),
},
};

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ const i18nTexts = {
}
),
},
frozen: {
body: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.frozen.nodeAttributesMissingDescription',
{
defaultMessage:
'Define custom node attributes in elasticsearch.yml to use attribute-based allocation. Frozen nodes will be used instead.',
}
),
},
};

export const NoNodeAttributesWarning: FunctionComponent<{ phase: PhaseWithAllocation }> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ function getTimingLabelForPhase(phase: keyof Phases) {
defaultMessage: 'Timing for cold phase',
});

case 'frozen':
return i18n.translate('xpack.indexLifecycleMgmt.editPolicy.phaseFrozen.minimumAgeLabel', {
defaultMessage: 'Timing for frozen phase',
});

case 'delete':
return i18n.translate('xpack.indexLifecycleMgmt.editPolicy.phaseDelete.minimumAgeLabel', {
defaultMessage: 'Timing for delete phase',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
} from '../../services/policies/policy_serialization';

import { ErrableFormRow, LearnMoreLink, PolicyJsonFlyout } from './components';
import { ColdPhase, DeletePhase, FrozenPhase, HotPhase, WarmPhase } from './phases';
import { ColdPhase, DeletePhase, HotPhase, WarmPhase } from './phases';

export interface Props {
policies: PolicyFromES[];
Expand Down Expand Up @@ -144,10 +144,6 @@ export const EditPolicy: React.FunctionComponent<Props> = ({
(key: string, value: any) => setPhaseData('cold', key, value),
[setPhaseData]
);
const setFrozenPhaseData = useCallback(
(key: string, value: any) => setPhaseData('frozen', key, value),
[setPhaseData]
);
const setDeletePhaseData = useCallback(
(key: string, value: any) => setPhaseData('delete', key, value),
[setPhaseData]
Expand Down Expand Up @@ -328,16 +324,6 @@ export const EditPolicy: React.FunctionComponent<Props> = ({

<EuiHorizontalRule />

<FrozenPhase
errors={errors?.frozen}
isShowingErrors={isShowingErrors && !!errors && Object.keys(errors.frozen).length > 0}
setPhaseData={setFrozenPhaseData}
phaseData={policy.phases.frozen}
hotPhaseRolloverEnabled={policy.phases.hot.rolloverEnabled}
/>

<EuiHorizontalRule />

<DeletePhase
errors={errors?.delete}
isShowingErrors={isShowingErrors && !!errors && Object.keys(errors.delete).length > 0}
Expand Down
Loading