From 4f8a0d2ee471b6c9bae4b4247d8c56f687dde2ba 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 | 61 +++++++++++++++++-- .../TenantResources/TenantSizeResources.tsx | 2 - 4 files changed, 72 insertions(+), 15 deletions(-) diff --git a/web-app/src/common/utils.ts b/web-app/src/common/utils.ts index 331b9b7bb91..b2827ed715b 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 zeroEC = "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..5b8b63afcbc 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, zeroEC } from "../../../../../common/utils"; const SizePreview = () => { const nodes = useSelector( @@ -139,7 +139,9 @@ const SizePreview = () => { Usable Capacity - {niceBytes(usableInformation.maxCapacity)} + {ecParity === zeroEC + ? 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 === zeroEC + ? 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..b431ec8b282 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 @@ -23,7 +23,7 @@ import { erasureCodeCalc, getBytes, k8sScalarUnitsExcluding, - niceBytes, + niceBytes, zeroEC, } from "../../../../../../common/utils"; import { clearValidationError } from "../../../utils"; import { ecListTransform } from "../../../ListTenants/utils"; @@ -91,6 +91,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 +270,11 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => { !("drivesps" in commonValidation) && distribution.error === "" && ecParityCalc.error === 0 && - ecParity !== "", + ecParity !== "" && + resourcesMemoryRequestError === "" && + resourcesCPURequestError === "" && + resourcesMemoryLimitError === "" && + resourcesCPULimitError === "", }), ); @@ -258,9 +294,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", zeroEC); + updateField("ecparityChoices", ecListTransform([zeroEC])); + updateField("cleanECChoices", [zeroEC]); + return; + } if (distribution.error === "") { // Get EC Value if (nodes.trim() !== "" && distribution.disks !== 0) { @@ -365,13 +416,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]);