-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CNV-33063: Add KSM to Cluster settings
Add KSM (Kernel Samepage Merging) configuration to Cluster settings, under "Resource management" expandable section. Fixes https://issues.redhat.com/browse/CNV-33063
- Loading branch information
Hilda Stastna
committed
Oct 12, 2023
1 parent
4c03b2d
commit f009437
Showing
8 changed files
with
153 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...SettingsTab/ClusterTab/components/ResourceManagementSection/ResourceManagementSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; | ||
|
||
import ExpandSection from '../../../ExpandSection/ExpandSection'; | ||
|
||
import KernelSamepageMerging from './components/KernelSamepageMerging/KernelSamepageMerging'; | ||
|
||
const ResourceManagementSection: FC = () => { | ||
const { t } = useKubevirtTranslation(); | ||
|
||
return ( | ||
<ExpandSection toggleText={t('Resource management')}> | ||
<KernelSamepageMerging /> | ||
</ExpandSection> | ||
); | ||
}; | ||
|
||
export default ResourceManagementSection; |
28 changes: 28 additions & 0 deletions
28
...nts/ResourceManagementSection/components/KernelSamepageMerging/KernelSamepageMerging.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.KernelSamepageMerging { | ||
&__ExpandSection { | ||
padding-left: var(--pf-global--spacer--lg); | ||
|
||
.pf-c-expandable-section__content { | ||
padding-left: var(--pf-global--spacer--lg); | ||
} | ||
|
||
.pf-c-expandable-section__toggle { | ||
padding-right: var(--pf-global--spacer--sm); | ||
} | ||
} | ||
|
||
&__HelpIcon, | ||
.pf-c-switch { | ||
vertical-align: -moz-middle-with-baseline !important; | ||
} | ||
|
||
&__HelpIcon { | ||
color: var(--pf-global--Color--100); | ||
} | ||
|
||
&__HelpTextIcon { | ||
.pf-c-popover__content { | ||
width: 400px; | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...ents/ResourceManagementSection/components/KernelSamepageMerging/KernelSamepageMerging.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { FC, useState } from 'react'; | ||
import ExpandSection from 'src/views/clusteroverview/SettingsTab/ExpandSection/ExpandSection'; | ||
|
||
import HelpTextIcon from '@kubevirt-utils/components/HelpTextIcon/HelpTextIcon'; | ||
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; | ||
import { PopoverPosition, Split, SplitItem, Switch } from '@patternfly/react-core'; | ||
|
||
import NodeSelectorConfiguration from './components/NodeSelectorConfiguration/NodeSelectorConfiguration'; | ||
|
||
import './KernelSamepageMerging.scss'; | ||
|
||
const KernelSamepageMerging: FC = () => { | ||
const { t } = useKubevirtTranslation(); | ||
const [isEnabled, setIsEnabled] = useState(false); | ||
// TODO enable KSM if isEnabled | ||
|
||
return ( | ||
<Split className="KernelSamepageMerging"> | ||
<SplitItem> | ||
<ExpandSection | ||
className="KernelSamepageMerging__ExpandSection" | ||
toggleContent={t('Kernel Samepage Merging (KSM)')} | ||
> | ||
<NodeSelectorConfiguration /> | ||
</ExpandSection> | ||
</SplitItem> | ||
<SplitItem isFilled> | ||
<HelpTextIcon | ||
bodyContent={t( | ||
'KSM is a memory-saving de-duplication feature designed to fit more VirtualMachines into physical memory by sharing the data common between them.', | ||
)} | ||
className="KernelSamepageMerging__HelpTextIcon" | ||
helpIconClassName="KernelSamepageMerging__HelpIcon" | ||
position={PopoverPosition.right} | ||
/> | ||
</SplitItem> | ||
<SplitItem> | ||
<Switch id="kernel-samepage-merging" isChecked={isEnabled} onChange={setIsEnabled} /> | ||
</SplitItem> | ||
</Split> | ||
); | ||
}; | ||
|
||
export default KernelSamepageMerging; |
48 changes: 48 additions & 0 deletions
48
.../KernelSamepageMerging/components/NodeSelectorConfiguration/NodeSelectorConfiguration.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { useWizardVMContext } from '@catalog/utils/WizardVMContext'; | ||
import { modelToGroupVersionKind, NodeModel } from '@kubevirt-ui/kubevirt-api/console'; | ||
import { IoK8sApiCoreV1Node } from '@kubevirt-ui/kubevirt-api/kubernetes'; | ||
import { useModal } from '@kubevirt-utils/components/ModalProvider/ModalProvider'; | ||
import NodeSelectorModal from '@kubevirt-utils/components/NodeSelectorModal/NodeSelectorModal'; | ||
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; | ||
import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk'; | ||
import { Button, ButtonVariant } from '@patternfly/react-core'; | ||
import { PencilAltIcon } from '@patternfly/react-icons'; | ||
|
||
const NodeSelectorConfiguration: FC = () => { | ||
const { createModal } = useModal(); | ||
const { t } = useKubevirtTranslation(); | ||
const { updateVM } = useWizardVMContext(); | ||
|
||
const [nodes, nodesLoaded] = useK8sWatchResource<IoK8sApiCoreV1Node[]>({ | ||
groupVersionKind: modelToGroupVersionKind(NodeModel), | ||
isList: true, | ||
}); | ||
|
||
const onNodeConfigure = () => | ||
createModal(({ isOpen, onClose }) => ( | ||
<NodeSelectorModal | ||
isOpen={isOpen} | ||
nodes={nodes} | ||
nodesLoaded={nodesLoaded} | ||
onClose={onClose} | ||
onSubmit={updateVM} | ||
vm={undefined} // TODO!!! | ||
/> | ||
)); | ||
|
||
return ( | ||
<Button | ||
className="NodeSelectorConfiguration__Button" | ||
isInline | ||
onClick={onNodeConfigure} | ||
variant={ButtonVariant.link} | ||
> | ||
{t('Node selector configuration')} | ||
<PencilAltIcon alt={t('Edit')} className="co-icon-space-l pf-c-button-icon--plain" /> | ||
</Button> | ||
); | ||
}; | ||
|
||
export default NodeSelectorConfiguration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters