Skip to content

Commit

Permalink
Update show/hide data tier logic
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jloleysens committed Oct 22, 2020
1 parent 62f34f2 commit 0bbca57
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,8 @@ describe('edit policy', () => {
test('should hide data tier option on cloud using legacy node role configuration', async () => {
http.setupNodeListResponse({
nodesByAttributes: { test: ['123'] },
nodesByRoles: { data: ['test'], data_hot: ['test'], data_warm: ['test'] },
// On cloud, if using legacy config there will not be any "data_*" roles set.
nodesByRoles: { data: ['test'] },
isUsingDeprecatedDataRoleConfig: true,
});
const rendered = mountWithIntl(component);
Expand Down
11 changes: 8 additions & 3 deletions x-pack/plugins/index_lifecycle_management/common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ export * from './api';
export * from './policies';

/**
* These roles reflect how nodes are stratified into different data tiers. The "data" role
* is a catch-all that can be used to store data in any phase.
* These roles reflect how nodes are stratified into different data tiers.
*
*/
export type NodeDataRole = 'data_hot' | 'data_warm' | 'data_cold';
export type NodeDataRoleWithCatchAll = 'data' | NodeDataRole;

/**
* The "data" role can store data on any tier and the "data_content" role can store
* all data the ES stack uses for feature functionality like security related indices.
*/
export type NodeDataRoleWithCatchAll = 'data' | 'data_content' | NodeDataRole;
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ export const DataTierAllocationField: FunctionComponent<Props> = ({
return (
<NodesDataProvider>
{({ nodesByRoles, nodesByAttributes, isUsingDeprecatedDataRoleConfig }) => {
const hasDataNodeRoles = Object.keys(nodesByRoles).some((nodeRole) =>
nodeRole.trim().startsWith('data_')
);
const hasNodeAttrs = Boolean(Object.keys(nodesByAttributes ?? {}).length);

const renderNotice = () => {
switch (phaseData.dataTierAllocationType) {
case 'default':
const isCloudEnabled = cloud?.isCloudEnabled ?? false;
if (isCloudEnabled && phase === 'cold') {
const isUsingNodeRolesAllocation = !isUsingDeprecatedDataRoleConfig;
const isUsingNodeRolesAllocation =
!isUsingDeprecatedDataRoleConfig && hasDataNodeRoles;
const hasNoNodesWithNodeRole = !nodesByRoles.data_cold?.length;

if (isUsingNodeRolesAllocation && hasNoNodesWithNodeRole) {
Expand Down Expand Up @@ -120,9 +124,9 @@ export const DataTierAllocationField: FunctionComponent<Props> = ({
phaseData={phaseData}
isShowingErrors={isShowingErrors}
nodes={nodesByAttributes}
disableDataTierOption={
!!(isUsingDeprecatedDataRoleConfig && cloud?.isCloudEnabled)
}
disableDataTierOption={Boolean(
cloud?.isCloudEnabled && !hasDataNodeRoles && isUsingDeprecatedDataRoleConfig
)}
/>

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

0 comments on commit 0bbca57

Please sign in to comment.