[ILM] Hide node allocation notices on Cloud (#94581)

* block node allocation notices on cloud

* added test to check that notices are not showing

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Jean-Louis Leysens 2021-03-16 13:40:13 +01:00 committed by GitHub
parent 638f166f71
commit 4a83a02433
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 96 deletions

View file

@ -365,9 +365,9 @@ describe('<EditPolicy /> node allocation', () => {
await act(async () => {
testBed = await setup({ appServicesContext: { cloud: { isCloudEnabled: true } } });
});
const { actions, component, exists, find } = testBed;
testBed.component.update();
component.update();
const { actions, component, exists, find } = testBed;
await actions.warm.enable(true);
expect(component.find('.euiLoadingSpinner').exists()).toBeFalsy();
@ -375,35 +375,29 @@ describe('<EditPolicy /> node allocation', () => {
expect(exists('defaultDataAllocationOption')).toBeTruthy();
expect(exists('customDataAllocationOption')).toBeTruthy();
expect(exists('noneDataAllocationOption')).toBeTruthy();
// We should not be showing the call-to-action for users to activate data tier in cloud
expect(exists('cloudDataTierCallout')).toBeFalsy();
// Do not show the call-to-action for users to migrate their cluster to use node roles
expect(find('cloudDataTierCallout').exists()).toBeFalsy();
});
test(`shows cloud notice when cold tier nodes do not exist`, async () => {
test('do not show node allocation specific warnings on cloud', async () => {
httpRequestsMockHelpers.setListNodes({
nodesByAttributes: {},
nodesByRoles: { data: ['test'], data_hot: ['test'], data_warm: ['test'] },
nodesByAttributes: { test: ['123'] },
// No nodes with node roles like "data_hot" or "data_warm"
nodesByRoles: {},
isUsingDeprecatedDataRoleConfig: false,
});
await act(async () => {
testBed = await setup({ appServicesContext: { cloud: { isCloudEnabled: true } } });
});
const { actions, component, exists, find } = testBed;
testBed.component.update();
component.update();
const { actions, component, exists } = testBed;
await actions.warm.enable(true);
await actions.cold.enable(true);
expect(component.find('.euiLoadingSpinner').exists()).toBeFalsy();
expect(exists('cloudMissingTierCallout')).toBeTruthy();
expect(find('cloudMissingTierCallout').text()).toContain(
`Edit your Elastic Cloud deployment to set up a cold tier`
);
// Assert that other notices are not showing
expect(actions.cold.hasDefaultAllocationNotice()).toBeFalsy();
expect(actions.cold.hasNoNodeAttrsWarning()).toBeFalsy();
expect(exists('cloudDataTierCallout')).toBeFalsy();
expect(exists('defaultAllocationNotice')).toBeFalsy();
expect(exists('defaultAllocationWarning')).toBeFalsy();
});
});
});

View file

@ -17,8 +17,6 @@ export { DefaultAllocationWarning } from './default_allocation_warning';
export { NoNodeAttributesWarning } from './no_node_attributes_warning';
export { MissingCloudTierCallout } from './missing_cloud_tier_callout';
export { CloudDataTierCallout } from './cloud_data_tier_callout';
export { LoadingError } from './loading_error';

View file

@ -1,53 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { i18n } from '@kbn/i18n';
import React, { FunctionComponent } from 'react';
import { EuiCallOut, EuiLink } from '@elastic/eui';
const geti18nTexts = (tier: 'cold' | 'frozen') => ({
title: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.cloudMissingTierCallout.title', {
defaultMessage: 'Create a {tier} tier',
values: { tier },
}),
body: i18n.translate('xpack.indexLifecycleMgmt.editPolicy.cloudMissingTierCallout.body', {
defaultMessage: 'Edit your Elastic Cloud deployment to set up a {tier} tier.',
values: { tier },
}),
linkText: i18n.translate(
'xpack.indexLifecycleMgmt.editPolicy.cloudMissingTierCallout.linkToCloudDeploymentDescription',
{ defaultMessage: 'View cloud deployment' }
),
});
interface Props {
phase: 'cold' | 'frozen';
linkToCloudDeployment?: string;
}
/**
* A call-to-action for users to activate their cold tier slider to provision cold tier nodes.
* This may need to be change when we have autoscaling enabled on a cluster because nodes may not
* yet exist, but will automatically be provisioned.
*/
export const MissingCloudTierCallout: FunctionComponent<Props> = ({
phase,
linkToCloudDeployment,
}) => {
const i18nTexts = geti18nTexts(phase);
return (
<EuiCallOut title={i18nTexts.title} data-test-subj="cloudMissingTierCallout">
{i18nTexts.body}{' '}
{Boolean(linkToCloudDeployment) && (
<EuiLink href={linkToCloudDeployment} external>
{i18nTexts.linkText}
</EuiLink>
)}
</EuiCallOut>
);
};

View file

@ -25,7 +25,6 @@ import {
DefaultAllocationNotice,
DefaultAllocationWarning,
NoNodeAttributesWarning,
MissingCloudTierCallout,
CloudDataTierCallout,
LoadingError,
} from './components';
@ -59,10 +58,6 @@ export const DataTierAllocationField: FunctionComponent<Props> = ({ phase, descr
const { nodesByRoles, nodesByAttributes, isUsingDeprecatedDataRoleConfig } = data!;
const hasDataNodeRoles = Object.keys(nodesByRoles).some((nodeRole) =>
// match any of the "data_" roles, including data_content.
nodeRole.trim().startsWith('data_')
);
const hasNodeAttrs = Boolean(Object.keys(nodesByAttributes ?? {}).length);
const isCloudEnabled = cloud?.isCloudEnabled ?? false;
const cloudDeploymentUrl = cloud?.cloudDeploymentUrl;
@ -71,26 +66,12 @@ export const DataTierAllocationField: FunctionComponent<Props> = ({ phase, descr
switch (allocationType) {
case 'node_roles':
/**
* We'll drive Cloud users to add a cold or frozen tier to their deployment if there are no nodes with that role.
* On cloud most users should be using autoscaling which will provision tiers as they are needed. We do not surface any
* of the notices below.
*/
if (
isCloudEnabled &&
!isUsingDeprecatedDataRoleConfig &&
(phase === 'cold' || phase === 'frozen')
) {
const hasNoNodesWithNodeRole = !nodesByRoles[`data_${phase}` as const]?.length;
if (hasDataNodeRoles && hasNoNodesWithNodeRole) {
// Tell cloud users they can deploy nodes on cloud.
return (
<>
<EuiSpacer size="s" />
<MissingCloudTierCallout phase={phase} linkToCloudDeployment={cloudDeploymentUrl} />
</>
);
}
if (isCloudEnabled) {
return null;
}
/**
* Node role allocation moves data in a phase to a corresponding tier of the same name. To prevent policy execution from getting
* stuck ILM allocation will fall back to a previous tier if possible. We show the WARNING below to inform a user when even