-
Notifications
You must be signed in to change notification settings - Fork 41
Resolves: MTV-3380 | Allow setting converter pod label, node selectors and affinities #2260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
avivtur
wants to merge
2
commits into
kubev2v:main
Choose a base branch
from
avivtur:feature/MTV-3380-importer-pod-scheduling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
4 changes: 2 additions & 2 deletions
4
src/components/AffinityViewDetailsItemContent/AffinityViewDetailsItemContent.tsx
This file contains hidden or 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 hidden or 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 hidden or 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
63 changes: 63 additions & 0 deletions
63
.../components/SettingsSection/components/ConvertorAffinity/ConvertorAffinityDetailsItem.tsx
This file contains hidden or 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,63 @@ | ||
| import type { FC } from 'react'; | ||
| import { isPlanEditable } from 'src/plans/details/components/PlanStatus/utils/utils'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: partially addressed from previous review — |
||
|
|
||
| import AffinityModal, { type AffinityModalProps } from '@components/AffinityModal/AffinityModal'; | ||
| import AffinityViewDetailsItemContent from '@components/AffinityViewDetailsItemContent/AffinityViewDetailsItemContent'; | ||
| import { DetailsItem } from '@components/DetailItems/DetailItem'; | ||
| import type { K8sIoApiCoreV1Affinity, V1beta1Plan } from '@forklift-ui/types'; | ||
| import { useModal } from '@openshift-console/dynamic-plugin-sdk'; | ||
| import { useForkliftTranslation } from '@utils/i18n'; | ||
| import { DOC_MAIN_HELP_LINK } from '@utils/links'; | ||
|
|
||
| import type { EditableDetailsItemProps } from '../../../utils/types'; | ||
| import { patchPlanSpec } from '../../utils/patchPlanSpec'; | ||
|
|
||
| const ConvertorAffinityDetailsItem: FC<EditableDetailsItemProps> = ({ | ||
| canPatch, | ||
| plan, | ||
| shouldRender, | ||
| }) => { | ||
| const { t } = useForkliftTranslation(); | ||
| const launcher = useModal(); | ||
|
|
||
| if (!shouldRender) { | ||
| return null; | ||
| } | ||
|
|
||
| const description = t( | ||
| 'Specify affinity rules for virt-v2v convertor pods during migration. This can apply hard and soft affinity and anti-affinity rules for convertor pods against workloads and nodes - for performance optimization (co-locating with storage) and ensuring network proximity to source infrastructure.', | ||
| ); | ||
|
|
||
| const onConfirm = async (updatedAffinity: K8sIoApiCoreV1Affinity): Promise<V1beta1Plan> => | ||
| patchPlanSpec({ | ||
| currentValue: plan?.spec?.convertorAffinity, | ||
| newValue: updatedAffinity, | ||
| path: '/spec/convertorAffinity', | ||
| plan, | ||
| }); | ||
|
|
||
| return ( | ||
| <DetailsItem | ||
| testId="convertor-affinity-rules-detail-item" | ||
| title={t('Convertor pod affinity rules')} | ||
| content={ | ||
| <AffinityViewDetailsItemContent | ||
| affinity={plan?.spec?.convertorAffinity as K8sIoApiCoreV1Affinity} | ||
| /> | ||
| } | ||
| helpContent={description} | ||
| crumbs={['spec', 'convertorAffinity']} | ||
| moreInfoLink={DOC_MAIN_HELP_LINK} | ||
| onEdit={() => { | ||
| launcher<AffinityModalProps>(AffinityModal, { | ||
| initialAffinity: plan?.spec?.convertorAffinity as K8sIoApiCoreV1Affinity, | ||
| onConfirm, | ||
| title: t('Edit convertor pod affinity rules'), | ||
| }); | ||
| }} | ||
| canEdit={canPatch && isPlanEditable(plan)} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default ConvertorAffinityDetailsItem; | ||
70 changes: 70 additions & 0 deletions
70
...ails/components/SettingsSection/components/ConvertorLabels/ConvertorLabelsDetailsItem.tsx
This file contains hidden or 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,70 @@ | ||
| import type { FC } from 'react'; | ||
| import { isPlanEditable } from 'src/plans/details/components/PlanStatus/utils/utils'; | ||
|
|
||
| import { DetailsItem } from '@components/DetailItems/DetailItem'; | ||
| import LabelsModal, { type LabelsModalProps } from '@components/LabelsModal/LabelsModal'; | ||
| import LabelsViewDetailsItemContent from '@components/LabelsViewDetailsItemContent/LabelsViewDetailsItemContent'; | ||
| import type { V1beta1Plan } from '@forklift-ui/types'; | ||
| import { useModal } from '@openshift-console/dynamic-plugin-sdk'; | ||
| import { Stack, StackItem } from '@patternfly/react-core'; | ||
| import { ForkliftTrans, useForkliftTranslation } from '@utils/i18n'; | ||
| import { DOC_MAIN_HELP_LINK } from '@utils/links'; | ||
|
|
||
| import type { EditableDetailsItemProps } from '../../../utils/types'; | ||
| import { patchPlanSpec } from '../../utils/patchPlanSpec'; | ||
|
|
||
| const ConvertorLabelsDetailsItem: FC<EditableDetailsItemProps> = ({ | ||
| canPatch, | ||
| plan, | ||
| shouldRender, | ||
| }) => { | ||
| const { t } = useForkliftTranslation(); | ||
| const launcher = useModal(); | ||
|
|
||
| if (!shouldRender) { | ||
| return null; | ||
| } | ||
|
|
||
| const description = t( | ||
| 'Specify custom labels to apply to virt-v2v convertor pods during migration. This can help with organizational labeling, monitoring, or targeting convertor pods with network policies.', | ||
| ); | ||
|
|
||
| const onConfirm = async (newLabels: Record<string, string | null>): Promise<V1beta1Plan> => | ||
| patchPlanSpec({ | ||
| currentValue: plan?.spec?.convertorLabels, | ||
| newValue: newLabels, | ||
| path: '/spec/convertorLabels', | ||
| plan, | ||
| }); | ||
|
|
||
| return ( | ||
| <DetailsItem | ||
| testId="convertor-labels-detail-item" | ||
| title={t('Convertor pod labels')} | ||
| content={<LabelsViewDetailsItemContent labels={plan?.spec?.convertorLabels} />} | ||
| helpContent={description} | ||
| crumbs={['spec', 'convertorLabels']} | ||
| moreInfoLink={DOC_MAIN_HELP_LINK} | ||
| onEdit={() => { | ||
| launcher<LabelsModalProps>(LabelsModal, { | ||
| description: ( | ||
| <ForkliftTrans> | ||
| <Stack hasGutter> | ||
| <StackItem>{description}</StackItem> | ||
| <StackItem> | ||
| Enter <strong>key=value</strong> pair(s). For example: project=myProject | ||
| </StackItem> | ||
| </Stack> | ||
| </ForkliftTrans> | ||
| ), | ||
| initialLabels: plan?.spec?.convertorLabels, | ||
| onConfirm, | ||
| title: t('Edit convertor pod labels'), | ||
| }); | ||
| }} | ||
| canEdit={canPatch && isPlanEditable(plan)} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default ConvertorLabelsDetailsItem; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.