-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1559 from hstastna/KSM_to_Cluster_settings
CNV-33063: Add KSM to Cluster settings
- Loading branch information
Showing
8 changed files
with
125 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
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; |
11 changes: 11 additions & 0 deletions
11
...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,11 @@ | ||
.KernelSamepageMerging { | ||
&__HelpTextIcon { | ||
.pf-c-popover__content { | ||
width: 465px; | ||
} | ||
} | ||
|
||
&__Alert { | ||
margin-top: var(--pf-global--spacer--md); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...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,81 @@ | ||
import React, { FC, useState } from 'react'; | ||
|
||
import HyperConvergedModel from '@kubevirt-ui/kubevirt-api/console/models/HyperConvergedModel'; | ||
import HelpTextIcon from '@kubevirt-utils/components/HelpTextIcon/HelpTextIcon'; | ||
import useHyperConvergeConfiguration, { | ||
HyperConverged, | ||
} from '@kubevirt-utils/hooks/useHyperConvergeConfiguration'; | ||
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation'; | ||
import { isEmpty } from '@kubevirt-utils/utils/utils'; | ||
import { k8sPatch } from '@openshift-console/dynamic-plugin-sdk'; | ||
import { | ||
Alert, | ||
AlertVariant, | ||
PopoverPosition, | ||
Split, | ||
SplitItem, | ||
Switch, | ||
} from '@patternfly/react-core'; | ||
|
||
import './KernelSamepageMerging.scss'; | ||
|
||
const KernelSamepageMerging: FC = () => { | ||
const { t } = useKubevirtTranslation(); | ||
const [hyperConverge, hyperLoaded, hyperLoadingError] = useHyperConvergeConfiguration(); | ||
const ksmConfiguration = hyperConverge?.spec?.configuration?.ksmConfiguration; | ||
const [isEnabled, setIsEnabled] = useState( | ||
!!(ksmConfiguration && isEmpty(ksmConfiguration?.nodeLabelSelector)), // Empty nodeLabelSelector will enable KSM on every node. | ||
); | ||
const [error, setError] = useState(null); | ||
|
||
const onKSMchange = (value: boolean) => { | ||
k8sPatch<HyperConverged>({ | ||
data: [ | ||
{ | ||
op: 'replace', | ||
path: `/spec/configuration/ksmConfiguration/nodeLabelSelector`, | ||
value: value ? {} : null, | ||
}, | ||
], | ||
model: HyperConvergedModel, | ||
resource: hyperConverge, | ||
}) | ||
.then(() => setIsEnabled(value)) | ||
.catch((err) => setError(err.message)); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Split> | ||
<SplitItem isFilled> | ||
{t('Kernel Samepage Merging (KSM)')}{' '} | ||
<HelpTextIcon | ||
bodyContent={t( | ||
'KSM is a memory-saving deduplication feature designed to fit more VirtualMachines into physical memory by sharing the data common between them. It is specifically effective for similar VirtualMachines. KSM should only be used with trusted workloads. Turning this feature on enables it for all nodes in the cluster.', | ||
)} | ||
className="KernelSamepageMerging__HelpTextIcon" | ||
helpIconClassName="KernelSamepageMerging__HelpIcon" | ||
position={PopoverPosition.bottom} | ||
/> | ||
</SplitItem> | ||
{hyperLoaded && ( | ||
<SplitItem> | ||
<Switch id="kernel-samepage-merging" isChecked={isEnabled} onChange={onKSMchange} /> | ||
</SplitItem> | ||
)} | ||
</Split> | ||
{(error || hyperLoadingError) && ( | ||
<Alert | ||
className="KernelSamepageMerging__Alert" | ||
isInline | ||
title={t('An error occurred')} | ||
variant={AlertVariant.danger} | ||
> | ||
{error || hyperLoadingError} | ||
</Alert> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default KernelSamepageMerging; |
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