Skip to content

Commit 0bbca57

Browse files
committed
Update show/hide data tier logic
only show data tier options on cloud if the cluster is not using the deprecated node.data config and there is a data_* role present. this will likely be a role like data_content which will ensure that the cluster is configured with the new data tier roles.
1 parent 62f34f2 commit 0bbca57

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,8 @@ describe('edit policy', () => {
796796
test('should hide data tier option on cloud using legacy node role configuration', async () => {
797797
http.setupNodeListResponse({
798798
nodesByAttributes: { test: ['123'] },
799-
nodesByRoles: { data: ['test'], data_hot: ['test'], data_warm: ['test'] },
799+
// On cloud, if using legacy config there will not be any "data_*" roles set.
800+
nodesByRoles: { data: ['test'] },
800801
isUsingDeprecatedDataRoleConfig: true,
801802
});
802803
const rendered = mountWithIntl(component);

x-pack/plugins/index_lifecycle_management/common/types/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ export * from './api';
99
export * from './policies';
1010

1111
/**
12-
* These roles reflect how nodes are stratified into different data tiers. The "data" role
13-
* is a catch-all that can be used to store data in any phase.
12+
* These roles reflect how nodes are stratified into different data tiers.
13+
*
1414
*/
1515
export type NodeDataRole = 'data_hot' | 'data_warm' | 'data_cold';
16-
export type NodeDataRoleWithCatchAll = 'data' | NodeDataRole;
16+
17+
/**
18+
* The "data" role can store data on any tier and the "data_content" role can store
19+
* all data the ES stack uses for feature functionality like security related indices.
20+
*/
21+
export type NodeDataRoleWithCatchAll = 'data' | 'data_content' | NodeDataRole;

x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared/data_tier_allocation_field.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,18 @@ export const DataTierAllocationField: FunctionComponent<Props> = ({
5555
return (
5656
<NodesDataProvider>
5757
{({ nodesByRoles, nodesByAttributes, isUsingDeprecatedDataRoleConfig }) => {
58+
const hasDataNodeRoles = Object.keys(nodesByRoles).some((nodeRole) =>
59+
nodeRole.trim().startsWith('data_')
60+
);
5861
const hasNodeAttrs = Boolean(Object.keys(nodesByAttributes ?? {}).length);
5962

6063
const renderNotice = () => {
6164
switch (phaseData.dataTierAllocationType) {
6265
case 'default':
6366
const isCloudEnabled = cloud?.isCloudEnabled ?? false;
6467
if (isCloudEnabled && phase === 'cold') {
65-
const isUsingNodeRolesAllocation = !isUsingDeprecatedDataRoleConfig;
68+
const isUsingNodeRolesAllocation =
69+
!isUsingDeprecatedDataRoleConfig && hasDataNodeRoles;
6670
const hasNoNodesWithNodeRole = !nodesByRoles.data_cold?.length;
6771

6872
if (isUsingNodeRolesAllocation && hasNoNodesWithNodeRole) {
@@ -120,9 +124,9 @@ export const DataTierAllocationField: FunctionComponent<Props> = ({
120124
phaseData={phaseData}
121125
isShowingErrors={isShowingErrors}
122126
nodes={nodesByAttributes}
123-
disableDataTierOption={
124-
!!(isUsingDeprecatedDataRoleConfig && cloud?.isCloudEnabled)
125-
}
127+
disableDataTierOption={Boolean(
128+
cloud?.isCloudEnabled && !hasDataNodeRoles && isUsingDeprecatedDataRoleConfig
129+
)}
126130
/>
127131

128132
{/* Data tier related warnings and call-to-action notices */}

0 commit comments

Comments
 (0)