[ILM] Fix bug when clearing priority field (#70154)

This commit is contained in:
Alison Goryachev 2020-06-29 20:34:33 -04:00 committed by GitHub
parent e19b0b0262
commit 771f3ae098
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 4 deletions

View file

@ -14,6 +14,9 @@ export const DELETE_PHASE_POLICY = {
hot: {
min_age: '0ms',
actions: {
set_priority: {
priority: null,
},
rollover: {
max_size: '50gb',
},

View file

@ -8,7 +8,7 @@ import { act } from 'react-dom/test-utils';
import { registerTestBed, TestBed, TestBedConfig } from '../../../../../test_utils';
import { POLICY_NAME } from './contants';
import { POLICY_NAME } from './constants';
import { TestSubjects } from '../helpers';
import { EditPolicy } from '../../../public/application/sections/edit_policy';

View file

@ -9,7 +9,7 @@ import { act } from 'react-dom/test-utils';
import { setupEnvironment } from '../helpers/setup_environment';
import { EditPolicyTestBed, setup } from './edit_policy.helpers';
import { DELETE_PHASE_POLICY } from './contants';
import { DELETE_PHASE_POLICY } from './constants';
import { API_BASE_PATH } from '../../../common/constants';

View file

@ -193,8 +193,11 @@ const phaseFromES = (phase, phaseName, defaultEmptyPolicy) => {
}
if (actions.set_priority) {
policy[PHASE_INDEX_PRIORITY] = actions.set_priority.priority;
const { priority } = actions.set_priority;
policy[PHASE_INDEX_PRIORITY] = priority ?? '';
}
if (actions.wait_for_snapshot) {
policy[PHASE_WAIT_FOR_SNAPSHOT_POLICY] = actions.wait_for_snapshot.policy;
}
@ -311,6 +314,10 @@ export const phaseToES = (phase, originalEsPhase) => {
esPhase.actions.set_priority = {
priority: phase[PHASE_INDEX_PRIORITY],
};
} else if (phase[PHASE_INDEX_PRIORITY] === '') {
esPhase.actions.set_priority = {
priority: null,
};
}
if (phase[PHASE_WAIT_FOR_SNAPSHOT_POLICY]) {

View file

@ -34,7 +34,7 @@ const minAgeSchema = schema.maybe(schema.string());
const setPrioritySchema = schema.maybe(
schema.object({
priority: schema.number(),
priority: schema.nullable(schema.number()),
})
);