MGMT-23515: Use Network type support level#3465
MGMT-23515: Use Network type support level#3465LiorSoffer wants to merge 1 commit intoopenshift-assisted:masterfrom
Conversation
|
@LiorSoffer: This pull request references MGMT-23515 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.22.0" version, but no target version was set. DetailsIn response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
📝 WalkthroughWalkthroughNetwork-type constants and third‑party CNI logic were moved into a new Changes
Sequence Diagram(s)sequenceDiagram
participant UI as NetworkConfiguration UI
participant Dropdown as NetworkTypeDropdown
participant FeatureSvc as FeatureSupportLevelService
participant Cluster as Cluster State
UI->>Cluster: provide cluster context (isSNO, stack, viewerMode)
UI->>Dropdown: render with featureSupportLevelData
Dropdown->>FeatureSvc: getFeatureSupportLevel(NETWORK_TYPE_FEATURE_IDS[value])
FeatureSvc-->>Dropdown: supportLevel
Dropdown->>Dropdown: compute disabledReason via getFeatureDisabledReason(featureId, supportLevel)
alt disabled
Dropdown->>Cluster: set field value to NETWORK_TYPE_OVN (fallback)
end
Dropdown->>UI: render items with NewFeatureSupportLevelBadge/support state
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkTypeDropdown.tsx`:
- Around line 94-96: The badge is passed featureId={value} but supportLevel was
derived from the mapped feature id used earlier; update the
NewFeatureSupportLevelBadge call to pass the same mapped feature-id variable
that you used to compute supportLevel (i.e., replace featureId={value} with
featureId={the mapped feature id variable used on lines 80–83}) so the badge
identity and supportLevel are consistent, keeping the existing onClick
event.stopPropagation wrapper intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 34f5c746-03c0-488c-aed0-a7c7c152d49f
📒 Files selected for processing (1)
libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkTypeDropdown.tsx
.../ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkTypeDropdown.tsx
Show resolved
Hide resolved
|
/cherry-pick releases/v2.51 |
|
@LiorSoffer: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
| const featureId = NETWORK_TYPE_FEATURE_IDS[value]; | ||
| const supportLevel = featureId | ||
| ? getFeatureSupportLevel(featureId, featureSupportLevelData ?? undefined) | ||
| : undefined; |
There was a problem hiding this comment.
Since we're looking at support levels for all network types, it makes no sense to treat SDN as a special case. Move the logic for SDN here and let's also future proof in case any of the other network types become unsupported or unavailable in some configuration.
There was a problem hiding this comment.
for SDN I first look if isSDNSelectable that's why I treat it differently
There was a problem hiding this comment.
ignore my last comment I fixed it
There was a problem hiding this comment.
Nice. Now let's future proof and disable any option that might be unsupported or unavailable. Not just SDN.
| import { isThirdPartyCNI } from '../../utils'; | ||
| import { RED_HAT_CNI_SUPPORT_MATRIX_LINK } from '../../../../common/config/docs_links'; | ||
|
|
||
| const NETWORK_TYPE_FEATURE_IDS: Record<string, FeatureSupportLevelId> = { |
There was a problem hiding this comment.
We have feature support ids here, while values and labels are in a constants.ts file.
I'd move everything into one place. To one file (existing or new), maybe even one object.
You can take inspiration from https://github.com/openshift-assisted/assisted-installer-ui/blob/master/libs/ui-lib/lib/common/types/cpuArchitecture.ts#L52-L72
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: LiorSoffer The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Signed-off-by: Lior Soffer <liorsoffer1@gmail.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts (1)
198-200:⚠️ Potential issue | 🟠 MajorHandle the other network-type feature IDs here too.
NetworkTypeDropdown.tsxnow resolvesgetFeatureDisabledReason(...)for every entry inNETWORK_TYPE_FEATURE_IDS, but this switch only special-casesSDN_NETWORK_TYPE.OVN_NETWORK_TYPE,CISCO_ACI_NETWORK_TYPE,CILIUM_NETWORK_TYPE,CALICO_NETWORK_TYPE, andNONE_NETWORK_TYPEcurrently fall through toundefined, so unsupported/unavailable options stay selectable and the auto-fallback effect never runs.Possible fix
+const getGenericNetworkTypeDisabledReason = (isSupported: boolean) => + !isSupported ? 'This network type is not supported for the selected configuration.' : undefined; + export const getNewFeatureDisabledReason = ( featureId: FeatureId, cluster: Cluster | undefined, activeFeatureConfiguration: ActiveFeatureConfiguration, isSupported: boolean, @@ case 'SDN_NETWORK_TYPE': { return getSDNDisabledReason(cluster, isSupported); } + case 'OVN_NETWORK_TYPE': + case 'CISCO_ACI_NETWORK_TYPE': + case 'CILIUM_NETWORK_TYPE': + case 'CALICO_NETWORK_TYPE': + case 'NONE_NETWORK_TYPE': { + return getGenericNetworkTypeDisabledReason(isSupported); + } case 'NETWORK_TYPE_SELECTION': { return getNetworkTypeSelectionDisabledReason(cluster); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts` around lines 198 - 200, The switch in getFeatureDisabledReason currently only handles 'SDN_NETWORK_TYPE' causing other entries from NETWORK_TYPE_FEATURE_IDS (OVN_NETWORK_TYPE, CISCO_ACI_NETWORK_TYPE, CILIUM_NETWORK_TYPE, CALICO_NETWORK_TYPE, NONE_NETWORK_TYPE) to fall through; update the switch inside getFeatureDisabledReason to handle each of those IDs and return the appropriate disabled-reason helper (e.g., getOVNDisabledReason, getCiscoACIDisabledReason, getCiliumDisabledReason, getCalicoDisabledReason, or a shared getNetworkDisabledReason) or create those helper functions if missing so NetworkTypeDropdown.tsx gets a non-undefined result for every network-type feature.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts`:
- Around line 198-200: The switch in getFeatureDisabledReason currently only
handles 'SDN_NETWORK_TYPE' causing other entries from NETWORK_TYPE_FEATURE_IDS
(OVN_NETWORK_TYPE, CISCO_ACI_NETWORK_TYPE, CILIUM_NETWORK_TYPE,
CALICO_NETWORK_TYPE, NONE_NETWORK_TYPE) to fall through; update the switch
inside getFeatureDisabledReason to handle each of those IDs and return the
appropriate disabled-reason helper (e.g., getOVNDisabledReason,
getCiscoACIDisabledReason, getCiliumDisabledReason, getCalicoDisabledReason, or
a shared getNetworkDisabledReason) or create those helper functions if missing
so NetworkTypeDropdown.tsx gets a non-undefined result for every network-type
feature.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cd1d7a1d-ce91-4583-a487-af3fb08fdb3e
📒 Files selected for processing (13)
libs/ui-lib/lib/cim/components/ClusterDeployment/networkConfigurationValidation.tslibs/ui-lib/lib/common/components/clusterWizard/networkingSteps/NetworkTypeControlGroup.tsxlibs/ui-lib/lib/common/components/clusterWizard/networkingSteps/StackTypeControlGroup.tsxlibs/ui-lib/lib/common/components/clusterWizard/networkingSteps/VirtualIPControlGroup.tsxlibs/ui-lib/lib/common/config/constants.tslibs/ui-lib/lib/common/types/index.tslibs/ui-lib/lib/common/types/networkType.tslibs/ui-lib/lib/ocm/components/clusterConfiguration/manifestsConfiguration/CustomManifestsPage.tsxlibs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfiguration.tsxlibs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkTypeDropdown.tsxlibs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsxlibs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.tslibs/ui-lib/lib/ocm/components/utils.ts
💤 Files with no reviewable changes (3)
- libs/ui-lib/lib/common/config/constants.ts
- libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfiguration.tsx
- libs/ui-lib/lib/ocm/components/utils.ts
✅ Files skipped from review due to trivial changes (7)
- libs/ui-lib/lib/common/components/clusterWizard/networkingSteps/VirtualIPControlGroup.tsx
- libs/ui-lib/lib/cim/components/ClusterDeployment/networkConfigurationValidation.ts
- libs/ui-lib/lib/common/types/index.ts
- libs/ui-lib/lib/ocm/components/clusterConfiguration/manifestsConfiguration/CustomManifestsPage.tsx
- libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx
- libs/ui-lib/lib/common/components/clusterWizard/networkingSteps/StackTypeControlGroup.tsx
- libs/ui-lib/lib/common/components/clusterWizard/networkingSteps/NetworkTypeControlGroup.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkTypeDropdown.tsx`:
- Around line 46-55: The effect in NetworkTypeDropdown.tsx that forces
setValue(NETWORK_TYPE_OVN) when getFeatureDisabledReason(...) !== undefined
should early-return if the dropdown is disabled; modify the React.useEffect to
check the component's isDisabled prop (or the local variable controlling
disabled state) and skip calling setValue when isDisabled is true, so the effect
only updates Formik state when the control is interactive; keep the existing
checks on field.value, featureSupportLevelData, getFeatureDisabledReason and
only call setValue(NETWORK_TYPE_OVN) when the feature is unsupported AND
isDisabled is false.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 448d768a-ab8e-4da4-8f28-0e39bf5616b2
📒 Files selected for processing (13)
libs/ui-lib/lib/cim/components/ClusterDeployment/networkConfigurationValidation.tslibs/ui-lib/lib/common/components/clusterWizard/networkingSteps/NetworkTypeControlGroup.tsxlibs/ui-lib/lib/common/components/clusterWizard/networkingSteps/StackTypeControlGroup.tsxlibs/ui-lib/lib/common/components/clusterWizard/networkingSteps/VirtualIPControlGroup.tsxlibs/ui-lib/lib/common/config/constants.tslibs/ui-lib/lib/common/types/index.tslibs/ui-lib/lib/common/types/networkType.tslibs/ui-lib/lib/ocm/components/clusterConfiguration/manifestsConfiguration/CustomManifestsPage.tsxlibs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfiguration.tsxlibs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkTypeDropdown.tsxlibs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsxlibs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.tslibs/ui-lib/lib/ocm/components/utils.ts
💤 Files with no reviewable changes (3)
- libs/ui-lib/lib/ocm/components/utils.ts
- libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfiguration.tsx
- libs/ui-lib/lib/common/config/constants.ts
✅ Files skipped from review due to trivial changes (9)
- libs/ui-lib/lib/common/components/clusterWizard/networkingSteps/VirtualIPControlGroup.tsx
- libs/ui-lib/lib/common/types/index.ts
- libs/ui-lib/lib/ocm/components/clusterWizard/ClusterWizardContextProvider.tsx
- libs/ui-lib/lib/common/components/clusterWizard/networkingSteps/NetworkTypeControlGroup.tsx
- libs/ui-lib/lib/ocm/components/clusterConfiguration/manifestsConfiguration/CustomManifestsPage.tsx
- libs/ui-lib/lib/common/components/clusterWizard/networkingSteps/StackTypeControlGroup.tsx
- libs/ui-lib/lib/ocm/components/featureSupportLevels/featureStateUtils.ts
- libs/ui-lib/lib/common/types/networkType.ts
- libs/ui-lib/lib/cim/components/ClusterDeployment/networkConfigurationValidation.ts
| React.useEffect(() => { | ||
| if (field.value === NETWORK_TYPE_SDN && sdnDisabledReason) { | ||
| if ( | ||
| getFeatureDisabledReason( | ||
| NETWORK_TYPE_FEATURE_IDS[field.value], | ||
| featureSupportLevelData ?? undefined, | ||
| ) !== undefined | ||
| ) { | ||
| setValue(NETWORK_TYPE_OVN); | ||
| } | ||
| }, [sdnDisabledReason, field.value, setValue]); | ||
| }, [field.value, setValue, featureSupportLevelData, getFeatureDisabledReason]); |
There was a problem hiding this comment.
Skip the auto-fallback when the dropdown is disabled.
This effect still forces NETWORK_TYPE_OVN when the selected type becomes unavailable/unsupported, even if isDisabled is true. That lets a read-only control silently rewrite the displayed selection and Formik state.
💡 Suggested fix
React.useEffect(() => {
+ if (isDisabled) {
+ return;
+ }
if (
getFeatureDisabledReason(
NETWORK_TYPE_FEATURE_IDS[field.value],
featureSupportLevelData ?? undefined,
) !== undefined
) {
setValue(NETWORK_TYPE_OVN);
}
- }, [field.value, setValue, featureSupportLevelData, getFeatureDisabledReason]);
+ }, [field.value, isDisabled, setValue, featureSupportLevelData, getFeatureDisabledReason]);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| React.useEffect(() => { | |
| if (field.value === NETWORK_TYPE_SDN && sdnDisabledReason) { | |
| if ( | |
| getFeatureDisabledReason( | |
| NETWORK_TYPE_FEATURE_IDS[field.value], | |
| featureSupportLevelData ?? undefined, | |
| ) !== undefined | |
| ) { | |
| setValue(NETWORK_TYPE_OVN); | |
| } | |
| }, [sdnDisabledReason, field.value, setValue]); | |
| }, [field.value, setValue, featureSupportLevelData, getFeatureDisabledReason]); | |
| React.useEffect(() => { | |
| if (isDisabled) { | |
| return; | |
| } | |
| if ( | |
| getFeatureDisabledReason( | |
| NETWORK_TYPE_FEATURE_IDS[field.value], | |
| featureSupportLevelData ?? undefined, | |
| ) !== undefined | |
| ) { | |
| setValue(NETWORK_TYPE_OVN); | |
| } | |
| }, [field.value, isDisabled, setValue, featureSupportLevelData, getFeatureDisabledReason]); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkTypeDropdown.tsx`
around lines 46 - 55, The effect in NetworkTypeDropdown.tsx that forces
setValue(NETWORK_TYPE_OVN) when getFeatureDisabledReason(...) !== undefined
should early-return if the dropdown is disabled; modify the React.useEffect to
check the component's isDisabled prop (or the local variable controlling
disabled state) and skip calling setValue when isDisabled is true, so the effect
only updates Formik state when the control is interactive; keep the existing
checks on field.value, featureSupportLevelData, getFeatureDisabledReason and
only call setValue(NETWORK_TYPE_OVN) when the feature is unsupported AND
isDisabled is false.
jgyselov
left a comment
There was a problem hiding this comment.
See if you can simplify the imports 🙂
If we kept importing like this, we'd end up with hundreds of lines of imports and no-one wants that.
| import { DUAL_STACK, IPV4_STACK } from '../../../common/config'; | ||
| import { NETWORK_TYPE_OVN } from '../../../common/types/networkType'; |
There was a problem hiding this comment.
You could just import all from ./../../common
| NO_SUBNET_SET, | ||
| } from '../../../config'; | ||
| import { DUAL_STACK, IPV4_STACK, NO_SUBNET_SET } from '../../../config'; | ||
| import { NETWORK_TYPE_OVN, NETWORK_TYPE_SDN } from '../../../types/networkType'; |
There was a problem hiding this comment.
You could import from ../../../types
| import { NetworkConfigurationValues, HostSubnets } from '../../../types'; | ||
| import { NETWORK_TYPE_SDN, DUAL_STACK } from '../../../config'; | ||
| import { DUAL_STACK } from '../../../config'; | ||
| import { NETWORK_TYPE_SDN } from '../../../types/networkType'; |
There was a problem hiding this comment.
You could import from ../../../types
| import { getFieldId } from '../../../../common/components/ui/formik'; | ||
| import { isOciPlatformType, isThirdPartyCNI } from '../../utils'; | ||
| import { isOciPlatformType } from '../../utils'; | ||
| import { isThirdPartyCNI } from '../../../../common/types/networkType'; |
There was a problem hiding this comment.
You could import from ../../../../common
| import { useFeature } from '../../hooks/use-feature'; | ||
| import { isOciPlatformType, isThirdPartyCNI } from '../utils'; | ||
| import { isOciPlatformType } from '../utils'; | ||
| import { isThirdPartyCNI } from '../../../common/types/networkType'; |
There was a problem hiding this comment.
You could import from ../../../common
| const featureId = NETWORK_TYPE_FEATURE_IDS[value]; | ||
| const supportLevel = featureId | ||
| ? getFeatureSupportLevel(featureId, featureSupportLevelData ?? undefined) | ||
| : undefined; |
There was a problem hiding this comment.
Nice. Now let's future proof and disable any option that might be unsupported or unavailable. Not just SDN.
https://redhat.atlassian.net/browse/MGMT-23515
Summary by CodeRabbit
Updates
Bug Fixes