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 17, 2024
1 parent 302793d commit dfff5a8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ examples/**/obj/
public.crt
go_build_operator_
operator.iml
web-app/build/static/
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
erasureCodeCalc,
getBytes,
k8sScalarUnitsExcluding,
niceBytes,
niceBytes, zeroEC,
} from "../../../../../../common/utils";
import { clearValidationError } from "../../../utils";
import { ecListTransform } from "../../../ListTenants/utils";
Expand Down Expand Up @@ -268,13 +268,13 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
!("nodes" in commonValidation) &&
!("volume_size" in commonValidation) &&
!("drivesps" in commonValidation) &&
resourcesMemoryRequestError == "" &&
resourcesCPURequestError == "" &&
resourcesMemoryLimitError == "" &&
resourcesCPULimitError == "" &&
distribution.error === "" &&
ecParityCalc.error === 0 &&
ecParity !== "",
ecParity !== "" &&
resourcesMemoryRequestError === "" &&
resourcesCPURequestError === "" &&
resourcesMemoryLimitError === "" &&
resourcesCPULimitError === "",
}),
);

Expand All @@ -298,14 +298,18 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
resourcesCPURequest,
maxCPUsUse,
maxMemorySize,
resourcesMemoryRequestError,
resourcesCPURequestError,
resourcesMemoryLimitError,
resourcesCPULimitError,
]);

useEffect(() => {
// Trivial case
if (nodes.trim() === "1") {
updateField("ecParity", "EC:0");
updateField("ecparityChoices", ecListTransform([ecParity]));
updateField("cleanECChoices", [ecParity]);
updateField("ecParity", zeroEC);
updateField("ecparityChoices", ecListTransform([zeroEC]));
updateField("cleanECChoices", [zeroEC]);
return;
}
if (distribution.error === "") {
Expand All @@ -319,22 +323,19 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
if (untouchedECField) {
updateField("ecParity", "");
}
return;
})
.catch((err: any) => {
updateField("ecparityChoices", []);
dispatch(
isPageValid({
pageName: "tenantSize",
valid: false,
}),
);
updateField("ecParity", "");
});
}
}
// Reset values on error
updateField("ecparityChoices", ecListTransform([]));
updateField("cleanECChoices", []);
updateField("ecParity", "");
}, [distribution, dispatch, updateField, nodes, untouchedECField]);

/* End Validation of pages */
Expand Down Expand Up @@ -416,7 +417,6 @@ const TenantSize = ({ formToRender }: ITenantSizeProps) => {
}}
label="Erasure Code Parity"
disabled={selectedStorageClass === "" || ecParity === ""}
required
value={ecParity}
options={ecParityChoices}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { Fragment, useCallback, useEffect, useState } from "react";
import React, { Fragment, useCallback, useEffect } from "react";
import { Box, InputBox, Switch } from "mds";
import { useSelector } from "react-redux";
import floor from "lodash/floor";
Expand Down Expand Up @@ -51,6 +51,7 @@ const TenantSizeResources = () => {
(state: AppState) =>
state.createTenant.fields.tenantSize.resourcesSpecifyLimit,
);

const resourcesCPURequestError = useSelector(
(state: AppState) =>
state.createTenant.fields.tenantSize.resourcesCPURequestError,
Expand Down Expand Up @@ -84,8 +85,6 @@ const TenantSizeResources = () => {
state.createTenant.fields.tenantSize.resourcesMemoryLimit,
);

const [validationErrors, setValidationErrors] = useState<any>({});

// Common
const updateField = useCallback(
(field: string, value: any) => {
Expand All @@ -102,7 +101,6 @@ const TenantSizeResources = () => {

/*Debounce functions*/

// Validation
useEffect(() => {
dispatch(
isPageValid({
Expand Down

0 comments on commit dfff5a8

Please sign in to comment.