Skip to content

Commit

Permalink
[ILM] Absolute to relative time conversion (#87822) (#88453)
Browse files Browse the repository at this point in the history
* cleaning up unused types and legacy logic

* added new relative age logic with unit tests

* export the calculate relative timing function that returns millisecond values

* added exports to index.ts file

* copy update and test update

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
jloleysens and kibanamachine authored Jan 15, 2021
1 parent eadbf51 commit 94f5e4a
Show file tree
Hide file tree
Showing 5 changed files with 705 additions and 52 deletions.
19 changes: 0 additions & 19 deletions x-pack/plugins/index_lifecycle_management/common/types/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,6 @@ export interface PhaseWithMinAge {
selectedMinimumAgeUnits: string;
}

/**
* Different types of allocation markers we use in deserialized policies.
*
* default - use data tier based data allocation based on node roles -- this is ES best practice mode.
* custom - use node_attrs to allocate data to specific nodes
* none - do not move data anywhere when entering a phase
*/
export type DataTierAllocationType = 'default' | 'custom' | 'none';

export interface PhaseWithAllocationAction {
selectedNodeAttrs: string;
selectedReplicaCount: string;
/**
* A string value indicating allocation type. If unspecified we assume the user
* wants to use default allocation.
*/
dataTierAllocationType: DataTierAllocationType;
}

export interface PhaseWithIndexPriority {
phaseIndexPriority: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { DataTierAllocationType, AllocateAction, MigrateAction } from '../../../../common/types';

/**
* Determine what deserialized state the policy config represents.
*
* See {@DataTierAllocationType} for more information.
*/
export const determineDataTierAllocationTypeLegacy = (
actions: {
allocate?: AllocateAction;
migrate?: MigrateAction;
} = {}
): DataTierAllocationType => {
const { allocate, migrate } = actions;

if (migrate?.enabled === false) {
return 'none';
}

if (!allocate) {
return 'default';
}

if (
(allocate.require && Object.keys(allocate.require).length) ||
(allocate.include && Object.keys(allocate.include).length) ||
(allocate.exclude && Object.keys(allocate.exclude).length)
) {
return 'custom';
}

return 'default';
};
import { AllocateAction, MigrateAction } from '../../../../common/types';

export const determineDataTierAllocationType = (
actions: {
Expand Down
Loading

0 comments on commit 94f5e4a

Please sign in to comment.