From 84926857b742ae70e029e49a8ca928badf15b58e Mon Sep 17 00:00:00 2001 From: Allan Reid Date: Wed, 14 Feb 2024 18:16:06 -0800 Subject: [PATCH] Recommend trivial parity --- web-app/src/common/utils.ts | 2 + .../Tenants/AddTenant/Steps/SizePreview.tsx | 22 ++++--- .../Steps/TenantResources/TenantSize.tsx | 60 +++++++++++++++++-- .../TenantResources/TenantSizeResources.tsx | 2 - 4 files changed, 72 insertions(+), 14 deletions(-) diff --git a/web-app/src/common/utils.ts b/web-app/src/common/utils.ts index 331b9b7bb91..cb810526a44 100644 --- a/web-app/src/common/utils.ts +++ b/web-app/src/common/utils.ts @@ -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 }, diff --git a/web-app/src/screens/Console/Tenants/AddTenant/Steps/SizePreview.tsx b/web-app/src/screens/Console/Tenants/AddTenant/Steps/SizePreview.tsx index 80d49411713..69d22174311 100644 --- a/web-app/src/screens/Console/Tenants/AddTenant/Steps/SizePreview.tsx +++ b/web-app/src/screens/Console/Tenants/AddTenant/Steps/SizePreview.tsx @@ -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( @@ -139,7 +139,9 @@ const SizePreview = () => { Usable Capacity - {niceBytes(usableInformation.maxCapacity)} + {ecParity === EC0 + ? niceBytes(ecParityCalc.rawCapacity) + : niceBytes(usableInformation.maxCapacity)} @@ -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, + ) + : "-"} diff --git a/web-app/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSize.tsx b/web-app/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSize.tsx index dc189d89a0a..fe177de6f99 100644 --- a/web-app/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSize.tsx +++ b/web-app/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSize.tsx @@ -24,6 +24,7 @@ import { getBytes, k8sScalarUnitsExcluding, niceBytes, + EC0, } from "../../../../../../common/utils"; import { clearValidationError } from "../../../utils"; import { ecListTransform } from "../../../ListTenants/utils"; @@ -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({}); const [errorFlag, setErrorFlag] = useState(false); const [nodeError, setNodeError] = useState(""); @@ -238,7 +271,11 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => { !("drivesps" in commonValidation) && distribution.error === "" && ecParityCalc.error === 0 && - ecParity !== "", + ecParity !== "" && + resourcesMemoryRequestError === "" && + resourcesCPURequestError === "" && + resourcesMemoryLimitError === "" && + resourcesCPULimitError === "", }), ); @@ -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) { @@ -365,13 +417,13 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => { updateField("ecParity", value); }} label="Erasure Code Parity" - disabled={selectedStorageClass === ""} + disabled={selectedStorageClass === "" || ecParity === ""} value={ecParity} options={ecParityChoices} /> - 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. diff --git a/web-app/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSizeResources.tsx b/web-app/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSizeResources.tsx index 1dc1e38b00f..faa07dd77c2 100644 --- a/web-app/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSizeResources.tsx +++ b/web-app/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSizeResources.tsx @@ -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]);