Skip to content

Commit

Permalink
Add UI for setting inventory memory limits
Browse files Browse the repository at this point in the history
There are currently knobs that can be used to adjust the memory limit
for the `main` container, but not for the `inventory` container. This
can cause the inventory container to go into a crash loop on a large
deployment. Add the ability to bump the inventory memory limit  to avoid
this.

Fixes: https://issues.redhat.com/browse/MTV-1504

Signed-off-by: Jonathon Jongsma <[email protected]>
  • Loading branch information
jonner committed Nov 6, 2024
1 parent 82a85d1 commit 0457a84
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
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 0457a84

Please sign in to comment.