Skip to content

Commit

Permalink
[ILM] Fix bug when clearing priority field (elastic#70154)
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth authored and Bamieh committed Jul 1, 2020
1 parent 5b9e4d9 commit e34d342
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const DELETE_PHASE_POLICY = {
hot: {
min_age: '0ms',
actions: {
set_priority: {
priority: null,
},
rollover: {
max_size: '50gb',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const minAgeSchema = schema.maybe(schema.string());

const setPrioritySchema = schema.maybe(
schema.object({
priority: schema.number(),
priority: schema.nullable(schema.number()),
})
);

Expand Down

0 comments on commit e34d342

Please sign in to comment.