-
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
Merged
jloleysens
merged 10 commits into
elastic:master
from
jloleysens:ilm/notices-should-reflect-tier-preferences
Sep 30, 2020
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1590d58
Refactor allocation notices for tier preferences
jloleysens 9fa4d32
added some test coverage
jloleysens bd41a07
Merge branch 'master' into ilm/notices-should-reflect-tier-preferences
elasticmachine cb89871
Merge branch 'master' into ilm/notices-should-reflect-tier-preferences
elasticmachine 11ac90e
Implement copy feedback
jloleysens bc56463
Merge branch 'master' into ilm/notices-should-reflect-tier-preferences
elasticmachine 5619743
Minor refactors based on PR feedback
jloleysens 7775b06
expanded README.md with section on testing cluster state notices
jloleysens fe7a9b2
Merge branch 'master' into ilm/notices-should-reflect-tier-preferences
elasticmachine 1673ee8
Updated copy to reference policy and updated freeze description
jloleysens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!