Skip to content

Commit

Permalink
[ILM] Kibana should allow a min_age setting of 0ms in ILM policy phas…
Browse files Browse the repository at this point in the history
…es (#53719) (#54499)
  • Loading branch information
alisonelizabeth authored Jan 11, 2020
1 parent 050e797 commit ce6d6b5
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import sinon from 'sinon';
import { findTestSubject } from '@elastic/eui/lib/test';
import {
positiveNumbersAboveZeroErrorMessage,
numberRequiredMessage,
positiveNumberRequiredMessage,
numberRequiredMessage,
maximumAgeRequiredMessage,
maximumSizeRequiredMessage,
policyNameRequiredMessage,
Expand Down Expand Up @@ -243,17 +243,18 @@ describe('edit policy', () => {
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'warm');
setPhaseAfter(rendered, 'warm', '');
save(rendered);
expectedErrorMessages(rendered, [numberRequiredMessage]);
});
test('should show positive number required above zero error when trying to save warm phase with 0 for after', () => {
test('should allow 0 for phase timing', () => {
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'warm');
setPhaseAfter(rendered, 'warm', 0);
save(rendered);
expectedErrorMessages(rendered, [positiveNumbersAboveZeroErrorMessage]);
expectedErrorMessages(rendered, []);
});
test('should show positive number required error when trying to save warm phase with -1 for after', () => {
const rendered = mountWithIntl(component);
Expand Down Expand Up @@ -383,14 +384,14 @@ describe('edit policy', () => {
});
});
describe('cold phase', () => {
test('should show positive number required error when trying to save cold phase with 0 for after', () => {
test('should allow 0 for phase timing', () => {
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'cold');
setPhaseAfter(rendered, 'cold', 0);
save(rendered);
expectedErrorMessages(rendered, [positiveNumbersAboveZeroErrorMessage]);
expectedErrorMessages(rendered, []);
});
test('should show positive number required error when trying to save cold phase with -1 for after', () => {
const rendered = mountWithIntl(component);
Expand Down Expand Up @@ -464,14 +465,14 @@ describe('edit policy', () => {
});
});
describe('delete phase', () => {
test('should show positive number required error when trying to save delete phase with 0 for after', () => {
test('should allow 0 for phase timing', () => {
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'delete');
setPhaseAfter(rendered, 'delete', 0);
save(rendered);
expectedErrorMessages(rendered, [positiveNumbersAboveZeroErrorMessage]);
expectedErrorMessages(rendered, []);
});
test('should show positive number required error when trying to save delete phase with -1 for after', () => {
const rendered = mountWithIntl(component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const MinAgeInput = props => {
onChange={async e => {
setPhaseData(PHASE_ROLLOVER_MINIMUM_AGE, e.target.value);
}}
min={1}
min={0}
/>
</ErrableFormRow>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
export const defaultColdPhase = {
[PHASE_ENABLED]: false,
[PHASE_ROLLOVER_ALIAS]: '',
[PHASE_ROLLOVER_MINIMUM_AGE]: '',
[PHASE_ROLLOVER_MINIMUM_AGE]: 0,
[PHASE_ROLLOVER_MINIMUM_AGE_UNITS]: 'd',
[PHASE_NODE_ATTRS]: '',
[PHASE_REPLICA_COUNT]: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const defaultDeletePhase = {
[PHASE_ENABLED]: false,
[PHASE_ROLLOVER_ENABLED]: false,
[PHASE_ROLLOVER_ALIAS]: '',
[PHASE_ROLLOVER_MINIMUM_AGE]: '',
[PHASE_ROLLOVER_MINIMUM_AGE]: 0,
[PHASE_ROLLOVER_MINIMUM_AGE_UNITS]: 'd',
};
export const defaultEmptyDeletePhase = defaultDeletePhase;
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const defaultWarmPhase = {
[PHASE_ROLLOVER_ALIAS]: '',
[PHASE_FORCE_MERGE_SEGMENTS]: '',
[PHASE_FORCE_MERGE_ENABLED]: false,
[PHASE_ROLLOVER_MINIMUM_AGE]: '',
[PHASE_ROLLOVER_MINIMUM_AGE]: 0,
[PHASE_ROLLOVER_MINIMUM_AGE_UNITS]: 'd',
[PHASE_NODE_ATTRS]: '',
[PHASE_SHRINK_ENABLED]: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@ export const validatePhase = (type, phase, errors) => {
phaseErrors[numberedAttribute] = [numberRequiredMessage];
} else if (phase[numberedAttribute] < 0) {
phaseErrors[numberedAttribute] = [positiveNumberRequiredMessage];
} else if (
(numberedAttribute === PHASE_ROLLOVER_MINIMUM_AGE ||
numberedAttribute === PHASE_PRIMARY_SHARD_COUNT) &&
phase[numberedAttribute] < 1
) {
phaseErrors[numberedAttribute] = [positiveNumbersAboveZeroErrorMessage];
}
}
}
Expand Down

0 comments on commit ce6d6b5

Please sign in to comment.