Skip to content

Commit

Permalink
Fixed field reset for memory & cpu fields in new tenant size screen (#…
Browse files Browse the repository at this point in the history
…1593)

Also fixed an issue with memory limit selection in create tenant

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
  • Loading branch information
bexsoft authored Feb 17, 2022
1 parent 3307d6f commit 3606870
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
6 changes: 3 additions & 3 deletions portal-ui/src/screens/Console/Tenants/AddTenant/AddTenant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
wizardCommon,
} from "../../Common/FormComponents/common/styleLibrary";
import api from "../../../../common/api";
import { generatePoolName } from "../../../../common/utils";
import { generatePoolName, getBytes } from "../../../../common/utils";
import GenericWizard from "../../Common/GenericWizard/GenericWizard";
import { IWizardElement } from "../../Common/GenericWizard/types";
import { NewServiceAccount } from "../../Common/CredentialsPrompt/types";
Expand Down Expand Up @@ -280,7 +280,7 @@ const AddTenant = ({
}
if (fields.tenantSize.resourcesMemoryRequest !== "") {
dataSend.pools[0].resources.requests.memory = parseInt(
fields.tenantSize.resourcesMemoryRequest
getBytes(fields.tenantSize.resourcesMemoryRequest, "Gi", true)
);
}
}
Expand All @@ -297,7 +297,7 @@ const AddTenant = ({
}
if (fields.tenantSize.resourcesMemoryLimit !== "") {
dataSend.pools[0].resources.limits.memory = parseInt(
fields.tenantSize.resourcesMemoryLimit
getBytes(fields.tenantSize.resourcesMemoryLimit, "Gi", true)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,11 @@ const styles = (theme: Theme) =>

const SizePreview = ({
classes,
updateAddField,
isPageValid,
volumeSize,
sizeFactor,
drivesPerServer,
nodes,
memoryNode,
ecParity,
ecParityChoices,
cleanECChoices,
resourcesSize,
distribution,
ecParityCalc,
limitSize,
selectedStorageClass,
cpuToUse,
integrationSelection,
}: ISizePreviewProps) => {
Expand Down Expand Up @@ -253,7 +243,7 @@ const mapState = (state: AppState) => ({
sizeFactor: state.tenants.createTenant.fields.tenantSize.sizeFactor,
drivesPerServer: state.tenants.createTenant.fields.tenantSize.drivesPerServer,
nodes: state.tenants.createTenant.fields.tenantSize.nodes,
memoryNode: state.tenants.createTenant.fields.tenantSize.memoryNode,
memoryNode: state.tenants.createTenant.fields.tenantSize.resourcesMemoryRequest,
ecParity: state.tenants.createTenant.fields.tenantSize.ecParity,
ecParityChoices: state.tenants.createTenant.fields.tenantSize.ecParityChoices,
cleanECChoices: state.tenants.createTenant.fields.tenantSize.cleanECChoices,
Expand All @@ -263,7 +253,7 @@ const mapState = (state: AppState) => ({
limitSize: state.tenants.createTenant.fields.tenantSize.limitSize,
selectedStorageClass:
state.tenants.createTenant.fields.nameTenant.selectedStorageClass,
cpuToUse: state.tenants.createTenant.fields.tenantSize.cpuToUse,
cpuToUse: state.tenants.createTenant.fields.tenantSize.resourcesCPURequest,
integrationSelection:
state.tenants.createTenant.fields.tenantSize.integrationSelection,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,19 @@ const TenantSizeResources = ({
);

const baseCpuUse = Math.max(1, floor(maxAllocatableCPU / 2));
updateField("resourcesCPURequest", baseCpuUse);
if (resourcesCPURequest === "") {
updateField("resourcesCPURequest", baseCpuUse);
}

const baseMemoryUse = Math.max(2, floor(maxMemory / 2));
updateField("resourcesMemoryRequest", baseMemoryUse);
if (resourcesMemoryRequest === "") {
updateField("resourcesMemoryRequest", baseMemoryUse);
}
})
.catch((err: any) => {
updateField("maxMemorySize", 0);
updateField("resourcesCPURequest", "");
updateField("resourcesMemoryRequest", "");

console.error(err);
});
Expand Down

0 comments on commit 3606870

Please sign in to comment.