-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) * Refactor allocation notices for tier preferences - also removed the lingering "data_frozen" node role * added some test coverage * Implement copy feedback * Minor refactors based on PR feedback * expanded README.md with section on testing cluster state notices * Updated copy to reference policy and updated freeze description Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
c710567
commit 6237069
Showing
17 changed files
with
302 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/index_lifecycle_management/common/constants/data_tiers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
// Order of node roles matters here, the warm phase prefers allocating data | ||
// to the data_warm role. | ||
import { NodeDataRole, PhaseWithAllocation } from '../types'; | ||
|
||
const WARM_PHASE_NODE_PREFERENCE: NodeDataRole[] = ['data_warm', 'data_hot']; | ||
|
||
const COLD_PHASE_NODE_PREFERENCE: NodeDataRole[] = ['data_cold', 'data_warm', 'data_hot']; | ||
|
||
export const phaseToNodePreferenceMap: Record<PhaseWithAllocation, NodeDataRole[]> = Object.freeze({ | ||
warm: WARM_PHASE_NODE_PREFERENCE, | ||
cold: COLD_PHASE_NODE_PREFERENCE, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
...index_lifecycle_management/public/application/lib/data_tiers/check_phase_compatibility.ts
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
...ecycle_management/public/application/lib/data_tiers/get_available_node_roles_for_phase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
NodeDataRole, | ||
ListNodesRouteResponse, | ||
PhaseWithAllocation, | ||
} from '../../../../common/types'; | ||
|
||
import { phaseToNodePreferenceMap } from '../../../../common/constants'; | ||
|
||
export type AllocationNodeRole = NodeDataRole | 'none'; | ||
|
||
/** | ||
* Given a phase and current cluster node roles, determine which nodes the phase | ||
* will allocate data to. For instance, for the warm phase, with warm | ||
* tier nodes, we would expect "data_warm". | ||
* | ||
* If no nodes can be identified for allocation (very special case) then | ||
* we return "none". | ||
*/ | ||
export const getAvailableNodeRoleForPhase = ( | ||
phase: PhaseWithAllocation, | ||
nodesByRoles: ListNodesRouteResponse['nodesByRoles'] | ||
): AllocationNodeRole => { | ||
const preferredNodeRoles = phaseToNodePreferenceMap[phase]; | ||
|
||
// The 'data' role covers all node roles, so if we have at least one node with the data role | ||
// we can allocate to our first preference. | ||
if (nodesByRoles.data?.length) { | ||
return preferredNodeRoles[0]; | ||
} | ||
|
||
return preferredNodeRoles.find((role) => Boolean(nodesByRoles[role]?.length)) ?? 'none'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...x_lifecycle_management/public/application/lib/data_tiers/is_node_role_first_preference.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { NodeDataRole, PhaseWithAllocation } from '../../../../common/types'; | ||
import { phaseToNodePreferenceMap } from '../../../../common/constants'; | ||
|
||
export const isNodeRoleFirstPreference = (phase: PhaseWithAllocation, nodeRole: NodeDataRole) => { | ||
return phaseToNodePreferenceMap[phase][0] === nodeRole; | ||
}; |
111 changes: 111 additions & 0 deletions
111
...cation/sections/edit_policy/components/data_tier_allocation/default_allocation_notice.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import React, { FunctionComponent } from 'react'; | ||
import { EuiCallOut, EuiSpacer } from '@elastic/eui'; | ||
|
||
import { PhaseWithAllocation, NodeDataRole } from '../../../../../../common/types'; | ||
|
||
import { AllocationNodeRole } from '../../../../lib'; | ||
|
||
const i18nTextsNodeRoleToDataTier: Record<NodeDataRole, string> = { | ||
data_hot: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.dataTierHotLabel', { | ||
defaultMessage: 'hot', | ||
}), | ||
data_warm: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.dataTierWarmLabel', { | ||
defaultMessage: 'warm', | ||
}), | ||
data_cold: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.dataTierColdLabel', { | ||
defaultMessage: 'cold', | ||
}), | ||
}; | ||
|
||
const i18nTexts = { | ||
notice: { | ||
warm: { | ||
title: i18n.translate( | ||
'xpack.indexLifecycleMgmt.warmPhase.dataTier.defaultAllocationNotice.warm.title', | ||
{ defaultMessage: 'No nodes assigned to the warm tier' } | ||
), | ||
body: (nodeRole: NodeDataRole) => | ||
i18n.translate('xpack.indexLifecycleMgmt.warmPhase.dataTier.defaultAllocationNotice.warm', { | ||
defaultMessage: | ||
'This policy will move data in the warm phase to {tier} tier nodes instead.', | ||
values: { tier: i18nTextsNodeRoleToDataTier[nodeRole] }, | ||
}), | ||
}, | ||
cold: { | ||
title: i18n.translate( | ||
'xpack.indexLifecycleMgmt.warmPhase.dataTier.defaultAllocationNotice.cold.title', | ||
{ defaultMessage: 'No nodes assigned to the cold tier' } | ||
), | ||
body: (nodeRole: NodeDataRole) => | ||
i18n.translate('xpack.indexLifecycleMgmt.warmPhase.dataTier.defaultAllocationNotice.cold', { | ||
defaultMessage: | ||
'This policy will move data in the cold phase to {tier} tier nodes instead.', | ||
values: { tier: i18nTextsNodeRoleToDataTier[nodeRole] }, | ||
}), | ||
}, | ||
}, | ||
warning: { | ||
warm: { | ||
title: i18n.translate( | ||
'xpack.indexLifecycleMgmt.warmPhase.dataTier.defaultAllocationNotAvailableTitle', | ||
{ defaultMessage: 'No nodes assigned to the warm tier' } | ||
), | ||
body: i18n.translate( | ||
'xpack.indexLifecycleMgmt.warmPhase.dataTier.defaultAllocationNotAvailableBody', | ||
{ | ||
defaultMessage: | ||
'Assign at least one node to the warm or hot tier to use role-based allocation. The policy will fail to complete allocation if there are no available nodes.', | ||
} | ||
), | ||
}, | ||
cold: { | ||
title: i18n.translate( | ||
'xpack.indexLifecycleMgmt.coldPhase.dataTier.defaultAllocationNotAvailableTitle', | ||
{ defaultMessage: 'No nodes assigned to the cold tier' } | ||
), | ||
body: i18n.translate( | ||
'xpack.indexLifecycleMgmt.coldPhase.dataTier.defaultAllocationNotAvailableBody', | ||
{ | ||
defaultMessage: | ||
'Assign at least one node to the cold, warm, or hot tier to use role-based allocation. The policy will fail to complete allocation if there are no available nodes.', | ||
} | ||
), | ||
}, | ||
}, | ||
}; | ||
|
||
interface Props { | ||
phase: PhaseWithAllocation; | ||
targetNodeRole: AllocationNodeRole; | ||
} | ||
|
||
export const DefaultAllocationNotice: FunctionComponent<Props> = ({ phase, targetNodeRole }) => { | ||
const content = | ||
targetNodeRole === 'none' ? ( | ||
<EuiCallOut | ||
data-test-subj="defaultAllocationWarning" | ||
title={i18nTexts.warning[phase].title} | ||
color="warning" | ||
> | ||
{i18nTexts.warning[phase].body} | ||
</EuiCallOut> | ||
) : ( | ||
<EuiCallOut data-test-subj="defaultAllocationNotice" title={i18nTexts.notice[phase].title}> | ||
{i18nTexts.notice[phase].body(targetNodeRole)} | ||
</EuiCallOut> | ||
); | ||
|
||
return ( | ||
<> | ||
<EuiSpacer size="s" /> | ||
{content} | ||
</> | ||
); | ||
}; |
Oops, something went wrong.