-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ILM] Data tier notices should reflect tier preferences #78398
Changes from 5 commits
1590d58
9fa4d32
bd41a07
cb89871
11ac90e
bc56463
5619743
7775b06
fe7a9b2
1673ee8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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 determineAllocationNodeRole = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: a name that mentions "phase" would communicate the interaction between phase and node role to me, e.g. |
||
phase: PhaseWithAllocation, | ||
nodesByRoles: ListNodesRouteResponse['nodesByRoles'] | ||
): AllocationNodeRole => { | ||
// 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 phaseToNodePreferenceMap[phase][0]; | ||
} | ||
|
||
const preferredNodeRoles = phaseToNodePreferenceMap[phase]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Since we refer to |
||
return preferredNodeRoles.find((role) => Boolean(nodesByRoles[role]?.length)) ?? 'none'; | ||
}; |
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; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* 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.common.dataTier.hot', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should follow the i18n naming guidelines throughout this file: https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/GUIDELINE.md |
||
defaultMessage: 'hot', | ||
}), | ||
data_warm: i18n.translate('xpack.indexLifecycleMgmt.common.dataTier.warm', { | ||
defaultMessage: 'warm', | ||
}), | ||
data_cold: i18n.translate('xpack.indexLifecycleMgmt.common.dataTier.cold', { | ||
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: 'Data in the warm phase will be allocated 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: 'Data in the cold phase will be allocated 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} | ||
</> | ||
); | ||
}; |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love these comments!