fix serialization of rollover (#85582)
This commit is contained in:
parent
051bbf073e
commit
b24ee4b3ff
|
@ -300,4 +300,16 @@ describe('deserializer and serializer', () => {
|
|||
expect(result.phases.hot!.actions.shrink).toBeUndefined();
|
||||
expect(result.phases.warm!.actions.shrink).toBeUndefined();
|
||||
});
|
||||
|
||||
it('removes rollover action fields', () => {
|
||||
formInternal.phases.hot!.actions.rollover!.max_size = '';
|
||||
formInternal.phases.hot!.actions.rollover!.max_age = '';
|
||||
formInternal.phases.hot!.actions.rollover!.max_docs = '' as any;
|
||||
|
||||
const result = serializer(formInternal);
|
||||
|
||||
expect(result.phases.hot!.actions.rollover!.max_age).toBeUndefined();
|
||||
expect(result.phases.hot!.actions.rollover!.max_docs).toBeUndefined();
|
||||
expect(result.phases.hot!.actions.rollover!.max_size).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -43,12 +43,20 @@ export const createSerializer = (originalPolicy?: SerializedPolicy) => (
|
|||
if (draft.phases.hot?.actions) {
|
||||
const hotPhaseActions = draft.phases.hot.actions;
|
||||
if (hotPhaseActions.rollover && _meta.hot.useRollover) {
|
||||
if (hotPhaseActions.rollover.max_age) {
|
||||
if (updatedPolicy.phases.hot!.actions.rollover?.max_age) {
|
||||
hotPhaseActions.rollover.max_age = `${hotPhaseActions.rollover.max_age}${_meta.hot.maxAgeUnit}`;
|
||||
} else {
|
||||
delete hotPhaseActions.rollover.max_age;
|
||||
}
|
||||
|
||||
if (hotPhaseActions.rollover.max_size) {
|
||||
if (typeof updatedPolicy.phases.hot!.actions.rollover?.max_docs !== 'number') {
|
||||
delete hotPhaseActions.rollover.max_docs;
|
||||
}
|
||||
|
||||
if (updatedPolicy.phases.hot!.actions.rollover?.max_size) {
|
||||
hotPhaseActions.rollover.max_size = `${hotPhaseActions.rollover.max_size}${_meta.hot.maxStorageSizeUnit}`;
|
||||
} else {
|
||||
delete hotPhaseActions.rollover.max_size;
|
||||
}
|
||||
|
||||
if (!updatedPolicy.phases.hot!.actions?.forcemerge) {
|
||||
|
|
Loading…
Reference in a new issue