Skip to content

Commit

Permalink
Merge pull request #1384 from jonner/mtv-1504
Browse files Browse the repository at this point in the history
MTV-1504 | Add UI for setting inventory memory limits
  • Loading branch information
yaacov authored Nov 7, 2024
2 parents 82a85d1 + fb01a8d commit b1d5cd5
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"Edit Controller Memory limit": "Edit Controller Memory limit",
"Edit credentials": "Edit credentials",
"Edit Default Transfer Network": "Edit Default Transfer Network",
"Edit Inventory Container Memory limit": "Edit Inventory Container Memory limit",
"Edit mappings": "Edit mappings",
"Edit Maximum concurrent VM migrations": "Edit Maximum concurrent VM migrations",
"Edit migration plan target namespace": "Edit migration plan target namespace",
Expand Down Expand Up @@ -216,6 +217,7 @@
"Invalid password": "Invalid password",
"Invalid username": "Invalid username",
"Inventory": "Inventory",
"Inventory Container Memory limit": "Inventory Container Memory limit",
"Inventory server is not reachable. To troubleshoot, check the Forklift controller pod logs.": "Inventory server is not reachable. To troubleshoot, check the Forklift controller pod logs.",
"Issuer": "Issuer",
"Kubernetes name of the new migration Plan resource": "Kubernetes name of the new migration Plan resource",
Expand Down Expand Up @@ -354,6 +356,7 @@
"Please enter the interval in seconds for snapshot pooling, if empty default value will be used.": "Please enter the interval in seconds for snapshot pooling, if empty default value will be used.",
"Please enter the limit for CPU usage by the controller in milliCPU, if empty default value will be used.": "Please enter the limit for CPU usage by the controller in milliCPU, if empty default value will be used.",
"Please enter the limit for memory usage by the controller in Mi, if empty default value will be used.": "Please enter the limit for memory usage by the controller in Mi, if empty default value will be used.",
"Please enter the limit for memory usage by the inventory container in Mi, if empty default value will be used.": "Please enter the limit for memory usage by the inventory container in Mi, if empty default value will be used.",
"Please enter the maximum number of concurrent VM migrations, if empty default value will be used.": "Please enter the maximum number of concurrent VM migrations, if empty default value will be used.",
"Pod": "Pod",
"Pod logs": "Pod logs",
Expand Down Expand Up @@ -423,6 +426,7 @@
"Set to preserve the static IPs": "Set to preserve the static IPs",
"Set warm migration": "Set warm migration",
"Sets the maximum number of VMs that can be migrated simultaneously. The default value is 20 virtual machines.": "Sets the maximum number of VMs that can be migrated simultaneously. The default value is 20 virtual machines.",
"Sets the memory limits allocated to the inventory container in the controller pod. The default value is 1000Mi.": "Sets the memory limits allocated to the inventory container in the controller pod. The default value is 1000Mi.",
"Sets the memory limits allocated to the main container in the controller pod. The default value is 800Mi.": "Sets the memory limits allocated to the main container in the controller pod. The default value is 800Mi.",
"Settings": "Settings",
"SHA-1 fingerprint": "SHA-1 fingerprint",
Expand Down Expand Up @@ -475,6 +479,7 @@
"The interval in seconds for snapshot pooling. Default value is 10.": "The interval in seconds for snapshot pooling. Default value is 10.",
"The limit for CPU usage by the controller, specified in milliCPU. Default value is 500m.": "The limit for CPU usage by the controller, specified in milliCPU. Default value is 500m.",
"The limit for memory usage by the controller, specified in Megabytes (Mi). Default value is 800Mi.": "The limit for memory usage by the controller, specified in Megabytes (Mi). Default value is 800Mi.",
"The limit for memory usage by the inventory container, specified in Megabytes (Mi). Default value is 1000Mi.": "The limit for memory usage by the inventory container, specified in Megabytes (Mi). Default value is 1000Mi.",
"The Manager CA certificate unless it was replaced by a third-party certificate, in which case, enter the Manager Apache CA certificate.": "The Manager CA certificate unless it was replaced by a third-party certificate, in which case, enter the Manager Apache CA certificate.",
"The password for the ESXi host admin": "The password for the ESXi host admin",
"The plan is not ready - ": "The plan is not ready - ",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import { EditModal, ModalInputComponentType } from 'src/modules/Providers/modals';
import { useForkliftTranslation } from 'src/utils/i18n';

import { ForkliftControllerModel } from '@kubev2v/types';
import { ModalVariant } from '@patternfly/react-core';

import { EditSettingsModalProps } from './EditSettingsModalProps';
import SettingsSelectInput from './SettingsSelectInput';

// Define the options
const options = [
{ key: '400Mi', name: '400Mi', description: 'Low memory limit' },
{ key: '1000Mi', name: '1000Mi', description: 'Moderate memory limit' },
{ key: '2000Mi', name: '2000Mi', description: 'High memory limit' },
{ key: '8000Mi', name: '8000Mi', description: 'Very high memory limit' },
];

/**
* InventoryMemoryLimitSelect component.
* Wraps the SettingsSelectInput component with pre-defined options.
*
* @param {ModalInputComponentProps} props - Properties passed to the component
* @returns {JSX.Element}
*/
const InventoryMemoryLimitSelect: ModalInputComponentType = (props) => {
return <SettingsSelectInput {...props} options={options} />;
};

export const EditInventoryMemoryLimitModal: React.FC<EditSettingsModalProps> = (props) => {
const { t } = useForkliftTranslation();

return (
<EditModal
{...props}
jsonPath={'spec.inventory_container_limits_memory'}
title={props?.title || t('Edit Inventory Container Memory limit')}
label={props?.label || t('Inventory Container Memory limit')}
model={ForkliftControllerModel}
variant={ModalVariant.small}
body={t(
'The limit for memory usage by the inventory container, specified in Megabytes (Mi). Default value is 1000Mi.',
)}
helperText={t(
'Please enter the limit for memory usage by the inventory container in Mi, if empty default value will be used.',
)}
InputComponent={InventoryMemoryLimitSelect}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @index(['./*', /style/g], f => `export * from '${f.path}';`)
export * from './EditControllerCPULimitModal';
export * from './EditControllerMemoryLimitModal';
export * from './EditInventoryMemoryLimitModal';
export * from './EditMaxVMInFlightModal';
export * from './EditPreCopyIntervalModal';
export * from './EditSettingsModalProps';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { FC } from 'react';
import {
EditControllerCPULimitModal,
EditControllerMemoryLimitModal,
EditInventoryMemoryLimitModal,
EditMaxVMInFlightModal,
EditPreCopyIntervalModal,
EditSnapshotPoolingIntervalModal,
Expand Down Expand Up @@ -98,6 +99,28 @@ const SettingsCard_: FC<SettingsCardProps> = ({ obj }) => {
onEdit={() => showModal(<EditControllerMemoryLimitModal resource={obj} />)}
/>

<DetailsItem
title={'Controller inventory container memory limit'}
showHelpIconNextToTitle={true}
content={
obj?.spec?.['inventory_container_limits_memory'] || (
<span className="text-muted">{'1000Mi'}</span>
)
}
moreInfoLink={
'https://docs.redhat.com/en/documentation/migration_toolkit_for_virtualization/2.6/html-single/installing_and_using_the_migration_toolkit_for_virtualization/index#advanced-migration-options_mtv'
}
helpContent={
<Text>
{t(
'Sets the memory limits allocated to the inventory container in the controller pod. The default value is 1000Mi.',
)}
</Text>
}
crumbs={['spec', 'inventory_container_limits_memory']}
onEdit={() => showModal(<EditInventoryMemoryLimitModal resource={obj} />)}
/>

<DetailsItem
title={'Precopy interval (minutes)'}
showHelpIconNextToTitle={true}
Expand Down

0 comments on commit b1d5cd5

Please sign in to comment.