Skip to content

Commit

Permalink
Recommend trivial parity
Browse files Browse the repository at this point in the history
  • Loading branch information
allanrogerr committed Feb 19, 2024
1 parent 7a4d426 commit 8492685
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 14 deletions.
2 changes: 2 additions & 0 deletions web-app/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ export const niceDaysInt = (seconds: number, timeVariant: string = "s") => {
}`;
};

export const EC0 = "EC:0";

export const MinIOEnvVarsSettings: any = {
MINIO_ACCESS_KEY: { secret: true },
MINIO_ACCESS_KEY_OLD: { secret: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import React, { Fragment } from "react";
import { Box, SimpleHeader, Table, TableBody, TableCell, TableRow } from "mds";
import { useSelector } from "react-redux";
import { AppState } from "../../../../../store";
import { niceBytes } from "../../../../../common/utils";
import { niceBytes, EC0 } from "../../../../../common/utils";

const SizePreview = () => {
const nodes = useSelector(
Expand Down Expand Up @@ -139,7 +139,9 @@ const SizePreview = () => {
<TableRow>
<TableCell scope="row">Usable Capacity</TableCell>
<TableCell sx={{ textAlign: "right" }}>
{niceBytes(usableInformation.maxCapacity)}
{ecParity === EC0
? niceBytes(ecParityCalc.rawCapacity)
: niceBytes(usableInformation.maxCapacity)}
</TableCell>
</TableRow>
<TableRow>
Expand All @@ -150,12 +152,16 @@ const SizePreview = () => {
style={{ borderBottom: 0 }}
sx={{ textAlign: "right" }}
>
{distribution
? Math.floor(
usableInformation.maxFailureTolerations /
distribution.disks,
)
: "-"}
{ecParity === EC0
? 0
: distribution &&
distribution.disks > 0 &&
usableInformation.maxFailureTolerations
? Math.floor(
usableInformation.maxFailureTolerations /
distribution.disks,
)
: "-"}
</TableCell>
</TableRow>
</TableBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
getBytes,
k8sScalarUnitsExcluding,
niceBytes,
EC0,
} from "../../../../../../common/utils";
import { clearValidationError } from "../../../utils";
import { ecListTransform } from "../../../ListTenants/utils";
Expand Down Expand Up @@ -91,6 +92,38 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
state.createTenant.fields.nameTenant.selectedStorageType,
);

const maxCPUsUse = useSelector(
(state: AppState) => state.createTenant.fields.tenantSize.maxCPUsUse,
);
const maxMemorySize = useSelector(
(state: AppState) => state.createTenant.fields.tenantSize.maxMemorySize,
);
const resourcesCPURequest = useSelector(
(state: AppState) =>
state.createTenant.fields.tenantSize.resourcesCPURequest,
);
const resourcesMemoryRequest = useSelector(
(state: AppState) =>
state.createTenant.fields.tenantSize.resourcesMemoryRequest,
);

const resourcesCPURequestError = useSelector(
(state: AppState) =>
state.createTenant.fields.tenantSize.resourcesCPURequestError,
);
const resourcesCPULimitError = useSelector(
(state: AppState) =>
state.createTenant.fields.tenantSize.resourcesCPULimitError,
);
const resourcesMemoryRequestError = useSelector(
(state: AppState) =>
state.createTenant.fields.tenantSize.resourcesMemoryRequestError,
);
const resourcesMemoryLimitError = useSelector(
(state: AppState) =>
state.createTenant.fields.tenantSize.resourcesMemoryLimitError,
);

const [validationErrors, setValidationErrors] = useState<any>({});
const [errorFlag, setErrorFlag] = useState<boolean>(false);
const [nodeError, setNodeError] = useState<string>("");
Expand Down Expand Up @@ -238,7 +271,11 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
!("drivesps" in commonValidation) &&
distribution.error === "" &&
ecParityCalc.error === 0 &&
ecParity !== "",
ecParity !== "" &&
resourcesMemoryRequestError === "" &&
resourcesCPURequestError === "" &&
resourcesMemoryLimitError === "" &&
resourcesCPULimitError === "",
}),
);

Expand All @@ -258,9 +295,24 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
nodeError,
drivesPerServer,
ecParity,
resourcesMemoryRequest,
resourcesCPURequest,
maxCPUsUse,
maxMemorySize,
resourcesMemoryRequestError,
resourcesCPURequestError,
resourcesMemoryLimitError,
resourcesCPULimitError,
]);

useEffect(() => {
// Trivial case
if (nodes.trim() === "1") {
updateField("ecParity", EC0);
updateField("ecparityChoices", ecListTransform([EC0]));
updateField("cleanECChoices", [EC0]);
return;
}
if (distribution.error === "") {
// Get EC Value
if (nodes.trim() !== "" && distribution.disks !== 0) {
Expand Down Expand Up @@ -365,13 +417,13 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
updateField("ecParity", value);
}}
label="Erasure Code Parity"
disabled={selectedStorageClass === ""}
disabled={selectedStorageClass === "" || ecParity === ""}
value={ecParity}
options={ecParityChoices}
/>
<Box className={"muted inputItem"}>
Please select the desired parity. This setting will change the max
usable capacity in the cluster
Please select the desired parity. This setting will change the maximum
usable capacity in the cluster.
</Box>

<TenantSizeResources />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ const TenantSizeResources = () => {
updateField("maxMemorySize", 0);
updateField("resourcesCPURequest", "");
updateField("resourcesMemoryRequest", "");

console.error(err);
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [nodes, updateField]);
Expand Down

0 comments on commit 8492685

Please sign in to comment.