Skip to content

Commit

Permalink
Fix location of Minimal Deployment message and calculation for Intern…
Browse files Browse the repository at this point in the history
…al Mode deployment
  • Loading branch information
bipuladh committed Aug 25, 2020
1 parent 685eef2 commit cd66904
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 24 deletions.
Expand Up @@ -44,11 +44,12 @@ import {
SelectNodesSection,
StorageClassSection,
EncryptSection,
MinimalDeploymentAlert,
} from '../../../utils/common-ocs-install-el';
import {
filterSCWithNoProv,
getAssociatedNodes,
shouldDeployMinimally,
shouldDeployAttachedAsMinimal,
} from '../../../utils/install';
import { getSCAvailablePVs } from '../../../selectors';
import '../ocs-install.scss';
Expand Down Expand Up @@ -94,7 +95,7 @@ export const CreateOCS = withHandlePromise<CreateOCSProps & HandlePromiseProps>(
);
const [pvData, pvLoaded, pvLoadError] = useK8sWatchResource<K8sResourceKind[]>(pvResource);

const isMinimal = shouldDeployMinimally(nodes);
const isMinimal = shouldDeployAttachedAsMinimal(nodes);

React.useEffect(() => {
// this is needed to ensure that the useEffect should be called only when setHasNoProvSC is defined
Expand Down Expand Up @@ -176,15 +177,7 @@ export const CreateOCS = withHandlePromise<CreateOCSProps & HandlePromiseProps>(
<SelectNodesSection
table={AttachedDevicesNodeTable}
customData={{ filteredNodes, nodes, setNodes }}
>
{isMinimal && (
<div className="ceph-ocs-install__minimal-msg">
Since the selected nodes do not satisfy the recommended requirements of 16 CPUs
and 64 GiB of RAM per node, a minimal cluster will be deployed, limited to a
single storage device set.
</div>
)}
</SelectNodesSection>
/>
</>
)}
{storageClass && filteredNodes?.length < minSelectedNode && (
Expand All @@ -204,6 +197,7 @@ export const CreateOCS = withHandlePromise<CreateOCSProps & HandlePromiseProps>(
</div>
</Alert>
)}
<>{isMinimal && <MinimalDeploymentAlert />}</>
<ButtonBar errorMessage={errorMessage} inProgress={inProgress}>
<ActionGroup className="pf-c-form">
<Button
Expand Down
Expand Up @@ -34,8 +34,9 @@ import {
SelectNodesSection,
StorageClassSection,
EncryptSection,
MinimalDeploymentAlert,
} from '../../utils/common-ocs-install-el';
import { filterSCWithoutNoProv, shouldDeployMinimally } from '../../utils/install';
import { filterSCWithoutNoProv, shouldDeployInternalAsMinimal } from '../../utils/install';
import { OCS_INTERNAL_CR_NAME } from '../../constants';
import './ocs-install.scss';

Expand Down Expand Up @@ -94,12 +95,28 @@ export const CreateInternalCluster = withHandlePromise<
const dispatch = useDispatch();
const [nodes, setNodes] = React.useState<NodeKind[]>([]);

const isMinimal = shouldDeployMinimally(nodes);
const isMinimal = shouldDeployInternalAsMinimal(nodes);
const [showMessage, setShowMessage] = React.useState(false);

const timeoutID = React.useRef(null);

React.useEffect(() => {
if (timeoutID.current !== null) {
clearTimeout(timeoutID.current);
}
if (nodes.length >= minSelectedNode) {
timeoutID.current = setTimeout(() => {
setShowMessage(true);
}, 1500);
} else {
setShowMessage(false);
}
}, [nodes, setShowMessage]);

const submit = (event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
// eslint-disable-next-line promise/catch-or-return
handlePromise(makeOCSRequest(nodes, storageClass, osdSize, isEncrypted), () => {
handlePromise(makeOCSRequest(nodes, storageClass, osdSize, isEncrypted, isMinimal), () => {
dispatch(setFlag(OCS_CONVERGED_FLAG, true));
dispatch(setFlag(OCS_INDEPENDENT_FLAG, false));
dispatch(setFlag(OCS_FLAG, true));
Expand Down Expand Up @@ -154,14 +171,9 @@ export const CreateInternalCluster = withHandlePromise<
Select at least 3 nodes in different zones you wish to use. The recommended
requirements are 16 CPUs and 64 GiB of RAM per node.
</div>
{isMinimal && (
<div className="ceph-ocs-install__minimal-msg">
Since the selected nodes do not satisfy the recommended requirements stated above, a
minimal cluster will be deployed, limited to a single storage device set.
</div>
)}
</>
</SelectNodesSection>
<>{isMinimal && showMessage && <MinimalDeploymentAlert isInternalMode />}</>
<ButtonBar errorMessage={errorMessage} inProgress={inProgress}>
<ActionGroup className="pf-c-form">
<Button
Expand Down
Expand Up @@ -43,3 +43,8 @@
margin-top: var(--pf-global--spacer--sm);
margin-bottom: var(--pf-global--spacer--sm);
}

.ceph-minimal-deployment-alert__header {
display: flex;
justify-content: space-between;
}
Expand Up @@ -52,7 +52,7 @@ export const getOCSRequestData = (
} as K8sResourceKind;

if (isMinimal) {
requestData.spec = {
requestData.spec = Object.assign(requestData.spec, {
resources: {
mds: {
limits: {
Expand All @@ -65,7 +65,7 @@ export const getOCSRequestData = (
},
},
},
};
});
}

if (provisioner === NO_PROVISIONER) {
Expand Down
Expand Up @@ -4,6 +4,7 @@ import { ListPage } from '@console/internal/components/factory';
import { NodeModel } from '@console/internal/models';
import { FieldLevelHelp } from '@console/internal/components/utils';
import { StorageClassResourceKind } from '@console/internal/module/k8s';
import { TechPreviewBadge } from '@console/shared';
import { OCSStorageClassDropdown } from '../components/modals/storage-class-dropdown';
import { storageClassTooltip } from '../constants/ocs-install';
import '../components/ocs-install/ocs-install.scss';
Expand All @@ -17,6 +18,30 @@ export const OCSAlert = () => (
/>
);

type MinimalDeploymentAlertProps = {
isInternalMode?: boolean;
};

export const MinimalDeploymentAlert: React.FC<MinimalDeploymentAlertProps> = ({
isInternalMode,
}) => (
<Alert
className="co-alert"
variant="warning"
title={
<div className="ceph-minimal-deployment-alert__header">
A minimal cluster deployment will be performed.
<TechPreviewBadge />
</div>
}
isInline
>
{isInternalMode
? 'The selected nodes do not match the OCS storage cluster minimum recommended requirements of an aggregated 30 CPUs and 72 GiB of RAM. If the selection won’t be modified, a minimal cluster will be deployed and may face some performance issues.'
: 'The selected nodes do not match the OCS storage cluster minimum recommended requirements of at least 10 CPU and 64 GiB of RAM per node. If the selection won’t be modified, a minimal cluster will be deployed and may face some performance issues.'}
</Alert>
);

export const SelectNodesSection: React.FC<SelectNodesSectionProps> = ({
table,
customData,
Expand Down
22 changes: 20 additions & 2 deletions frontend/packages/ceph-storage-plugin/src/utils/install.ts
Expand Up @@ -58,12 +58,30 @@ export const getAssociatedNodes = (pvs: K8sResourceKind[]): string[] => {
return Array.from(nodes);
};

export const shouldDeployMinimally = (nodes: NodeKind[]) =>
export const shouldDeployInternalAsMinimal = (nodes: NodeKind[]) => {
const { totalCPU, totalMemory } = nodes.reduce(
(acc, curr) => {
const cpus = humanizeCpuCores(getNodeCPUCapacity(curr)).value;
const memoryRaw = getNodeAllocatableMemory(curr);
const memory = humanizeBinaryBytes(convertToBaseValue(memoryRaw)).value;
acc.totalCPU += cpus;
acc.totalMemory += memory;
return acc;
},
{
totalCPU: 0,
totalMemory: 0,
},
);
return totalCPU < 30 || totalMemory < 60;
};

export const shouldDeployAttachedAsMinimal = (nodes: NodeKind[]) =>
nodes.reduce((acc, curr) => {
const cpus = humanizeCpuCores(getNodeCPUCapacity(curr)).value;
const memoryRaw = getNodeAllocatableMemory(curr);
const memory = humanizeBinaryBytes(convertToBaseValue(memoryRaw)).value;
if (memory < 60 || cpus < 16) {
if (memory < 60 || cpus < 10) {
return [...acc, curr];
}
return acc;
Expand Down

0 comments on commit cd66904

Please sign in to comment.