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

Recommend trivial parity #1988

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions web-app/src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -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 },
Original file line number Diff line number Diff line change
@@ -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 = () => {
<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>
@@ -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>
Original file line number Diff line number Diff line change
@@ -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<any>({});
const [errorFlag, setErrorFlag] = useState<boolean>(false);
const [nodeError, setNodeError] = useState<string>("");
@@ -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}
/>
<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 />
Original file line number Diff line number Diff line change
@@ -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]);