Skip to content

Commit 0eb342d

Browse files
authored
Recommend trivial parity (#1988)
1 parent 7a4d426 commit 0eb342d

File tree

4 files changed

+72
-14
lines changed

4 files changed

+72
-14
lines changed

web-app/src/common/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ export const niceDaysInt = (seconds: number, timeVariant: string = "s") => {
524524
}`;
525525
};
526526

527+
export const EC0 = "EC:0";
528+
527529
export const MinIOEnvVarsSettings: any = {
528530
MINIO_ACCESS_KEY: { secret: true },
529531
MINIO_ACCESS_KEY_OLD: { secret: true },

web-app/src/screens/Console/Tenants/AddTenant/Steps/SizePreview.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import React, { Fragment } from "react";
1818
import { Box, SimpleHeader, Table, TableBody, TableCell, TableRow } from "mds";
1919
import { useSelector } from "react-redux";
2020
import { AppState } from "../../../../../store";
21-
import { niceBytes } from "../../../../../common/utils";
21+
import { niceBytes, EC0 } from "../../../../../common/utils";
2222

2323
const SizePreview = () => {
2424
const nodes = useSelector(
@@ -139,7 +139,9 @@ const SizePreview = () => {
139139
<TableRow>
140140
<TableCell scope="row">Usable Capacity</TableCell>
141141
<TableCell sx={{ textAlign: "right" }}>
142-
{niceBytes(usableInformation.maxCapacity)}
142+
{ecParity === EC0
143+
? niceBytes(ecParityCalc.rawCapacity)
144+
: niceBytes(usableInformation.maxCapacity)}
143145
</TableCell>
144146
</TableRow>
145147
<TableRow>
@@ -150,12 +152,16 @@ const SizePreview = () => {
150152
style={{ borderBottom: 0 }}
151153
sx={{ textAlign: "right" }}
152154
>
153-
{distribution
154-
? Math.floor(
155-
usableInformation.maxFailureTolerations /
156-
distribution.disks,
157-
)
158-
: "-"}
155+
{ecParity === EC0
156+
? 0
157+
: distribution &&
158+
distribution.disks > 0 &&
159+
usableInformation.maxFailureTolerations
160+
? Math.floor(
161+
usableInformation.maxFailureTolerations /
162+
distribution.disks,
163+
)
164+
: "-"}
159165
</TableCell>
160166
</TableRow>
161167
</TableBody>

web-app/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSize.tsx

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
getBytes,
2525
k8sScalarUnitsExcluding,
2626
niceBytes,
27+
EC0,
2728
} from "../../../../../../common/utils";
2829
import { clearValidationError } from "../../../utils";
2930
import { ecListTransform } from "../../../ListTenants/utils";
@@ -91,6 +92,38 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
9192
state.createTenant.fields.nameTenant.selectedStorageType,
9293
);
9394

95+
const maxCPUsUse = useSelector(
96+
(state: AppState) => state.createTenant.fields.tenantSize.maxCPUsUse,
97+
);
98+
const maxMemorySize = useSelector(
99+
(state: AppState) => state.createTenant.fields.tenantSize.maxMemorySize,
100+
);
101+
const resourcesCPURequest = useSelector(
102+
(state: AppState) =>
103+
state.createTenant.fields.tenantSize.resourcesCPURequest,
104+
);
105+
const resourcesMemoryRequest = useSelector(
106+
(state: AppState) =>
107+
state.createTenant.fields.tenantSize.resourcesMemoryRequest,
108+
);
109+
110+
const resourcesCPURequestError = useSelector(
111+
(state: AppState) =>
112+
state.createTenant.fields.tenantSize.resourcesCPURequestError,
113+
);
114+
const resourcesCPULimitError = useSelector(
115+
(state: AppState) =>
116+
state.createTenant.fields.tenantSize.resourcesCPULimitError,
117+
);
118+
const resourcesMemoryRequestError = useSelector(
119+
(state: AppState) =>
120+
state.createTenant.fields.tenantSize.resourcesMemoryRequestError,
121+
);
122+
const resourcesMemoryLimitError = useSelector(
123+
(state: AppState) =>
124+
state.createTenant.fields.tenantSize.resourcesMemoryLimitError,
125+
);
126+
94127
const [validationErrors, setValidationErrors] = useState<any>({});
95128
const [errorFlag, setErrorFlag] = useState<boolean>(false);
96129
const [nodeError, setNodeError] = useState<string>("");
@@ -238,7 +271,11 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
238271
!("drivesps" in commonValidation) &&
239272
distribution.error === "" &&
240273
ecParityCalc.error === 0 &&
241-
ecParity !== "",
274+
ecParity !== "" &&
275+
resourcesMemoryRequestError === "" &&
276+
resourcesCPURequestError === "" &&
277+
resourcesMemoryLimitError === "" &&
278+
resourcesCPULimitError === "",
242279
}),
243280
);
244281

@@ -258,9 +295,24 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
258295
nodeError,
259296
drivesPerServer,
260297
ecParity,
298+
resourcesMemoryRequest,
299+
resourcesCPURequest,
300+
maxCPUsUse,
301+
maxMemorySize,
302+
resourcesMemoryRequestError,
303+
resourcesCPURequestError,
304+
resourcesMemoryLimitError,
305+
resourcesCPULimitError,
261306
]);
262307

263308
useEffect(() => {
309+
// Trivial case
310+
if (nodes.trim() === "1") {
311+
updateField("ecParity", EC0);
312+
updateField("ecparityChoices", ecListTransform([EC0]));
313+
updateField("cleanECChoices", [EC0]);
314+
return;
315+
}
264316
if (distribution.error === "") {
265317
// Get EC Value
266318
if (nodes.trim() !== "" && distribution.disks !== 0) {
@@ -365,13 +417,13 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
365417
updateField("ecParity", value);
366418
}}
367419
label="Erasure Code Parity"
368-
disabled={selectedStorageClass === ""}
420+
disabled={selectedStorageClass === "" || ecParity === ""}
369421
value={ecParity}
370422
options={ecParityChoices}
371423
/>
372424
<Box className={"muted inputItem"}>
373-
Please select the desired parity. This setting will change the max
374-
usable capacity in the cluster
425+
Please select the desired parity. This setting will change the maximum
426+
usable capacity in the cluster.
375427
</Box>
376428

377429
<TenantSizeResources />

web-app/src/screens/Console/Tenants/AddTenant/Steps/TenantResources/TenantSizeResources.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ const TenantSizeResources = () => {
183183
updateField("maxMemorySize", 0);
184184
updateField("resourcesCPURequest", "");
185185
updateField("resourcesMemoryRequest", "");
186-
187-
console.error(err);
188186
});
189187
// eslint-disable-next-line react-hooks/exhaustive-deps
190188
}, [nodes, updateField]);

0 commit comments

Comments
 (0)