Skip to content
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

Bug 1909821: Fix flexible scaling enablement #7643

Merged
merged 1 commit into from
Dec 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const ReviewAndCreate: React.FC<ReviewAndCreateProps> = ({
</p>
</ReviewListBody>
<ReviewListBody
noValue={!zones.size}
hideIcon={!enableFlexibleScaling || !stretchClusterChecked}
validation={enableFlexibleScaling && ValidationType.BAREMETAL_FLEXIBLE_SCALING}
>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
import {
getNodeInfo,
shouldDeployAsMinimal,
isFlexibleScaling,
filterSCWithNoProv,
getAssociatedNodes,
nodesWithoutTaints,
Expand All @@ -53,8 +54,7 @@ const validate = (
enableFlexibleScaling: boolean,
): ValidationType[] => {
const validations = [];
if (enableFlexibleScaling) {
// TODO: add check for arbiter
if (!stretchClusterChecked && enableFlexibleScaling) {
validations.push(ValidationType.BAREMETAL_FLEXIBLE_SCALING);
}
if (enableMinimal) {
Expand Down Expand Up @@ -84,7 +84,6 @@ export const StorageAndNodes: React.FC<StorageAndNodesProps> = ({ state, dispatc
} = state;

let scNodeNames: string[] = []; // names of the nodes, backing the storage of selected storage class
const scNodeNamesLength = scNodeNames.length;
const { cpu, memory, zones } = getNodeInfo(nodes);
const scName: string = state.storageClassName;
const validations: ValidationType[] = validate(
Expand All @@ -109,9 +108,13 @@ export const StorageAndNodes: React.FC<StorageAndNodesProps> = ({ state, dispatc
}, [cpu, dispatch, memory, nodesCount]);

React.useEffect(() => {
const isFlexibleScaling: boolean = scNodeNamesLength && zonesCount < 3;
dispatch({ type: 'setEnableFlexibleScaling', value: isFlexibleScaling });
}, [dispatch, zonesCount, scNodeNamesLength]);
if (!stretchClusterChecked) {
dispatch({
type: 'setEnableFlexibleScaling',
value: isFlexibleScaling(nodesCount, zonesCount),
});
}
}, [dispatch, zonesCount, nodesCount, stretchClusterChecked]);

const handleStorageClass = (sc: StorageClassResourceKind) => {
dispatch({ type: 'setStorageClass', value: sc });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const ReviewListBody: React.FC<ReviewListBodyProps> = ({

return (
<dd className="ocs-install-wizard__dd">
{!hideIcon ? (
{alert?.variant || !hideIcon ? (
<Split>
<SplitItem>
<Icon className="ocs-install-wizard__icon" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const ReviewAndCreate: React.FC<ReviewAndCreateProps> = ({
</p>
</ReviewListBody>
<ReviewListBody
hideIcon={!enableFlexibleScaling}
validation={enableFlexibleScaling && ValidationType.INTERNAL_FLEXIBLE_SCALING}
>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { InternalClusterState, InternalClusterAction, ActionType } from '../redu
import {
getNodeInfo,
shouldDeployAsMinimal,
isFlexibleScaling,
filterSCWithoutNoProv,
} from '../../../../utils/install';
import { ValidationMessage, ValidationType } from '../../../../utils/common-ocs-install-el';
Expand Down Expand Up @@ -66,8 +67,10 @@ export const SelectCapacityAndNodes: React.FC<SelectCapacityAndNodesProps> = ({
}, [cpu, dispatch, memory, nodesCount]);

React.useEffect(() => {
const isFlexibleScaling = nodesCount && zonesCount < 3;
dispatch({ type: ActionType.SET_ENABLE_FLEXIBLE_SCALING, payload: isFlexibleScaling });
dispatch({
type: ActionType.SET_ENABLE_FLEXIBLE_SCALING,
payload: isFlexibleScaling(nodesCount, zonesCount),
});
}, [dispatch, zonesCount, nodesCount]);

return (
Expand Down
2 changes: 2 additions & 0 deletions frontend/packages/ceph-storage-plugin/src/utils/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export const shouldDeployAsMinimal = (cpu: number, memory: number, nodesCount: n
return false;
};

export const isFlexibleScaling = (nodes, zones): boolean => !!(nodes >= MINIMUM_NODES && zones < 3);

export const countNodesPerZone = (nodes: NodeKind[]) =>
nodes.reduce((acc, curr) => {
const zone = getZone(curr);
Expand Down