Skip to content

Commit

Permalink
Use platform type to call support-levels API in Networking page (open…
Browse files Browse the repository at this point in the history
…shift-assisted#2372)

Co-authored-by: Jonathan Kilzi <[email protected]>
  • Loading branch information
ammont82 and jkilzi committed Sep 27, 2023
1 parent 6906e70 commit aa2af91
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Cluster,
ClusterDefaultConfig,
clusterNetworksEqual,
CpuArchitecture,
DUAL_STACK,
HostSubnets,
isSNO,
Expand All @@ -30,8 +31,10 @@ import { OcmCheckbox } from '../../ui/OcmFormFields';
import { NetworkTypeControlGroup } from '../../../../common/components/clusterWizard/networkingSteps/NetworkTypeControlGroup';
import {
NewFeatureSupportLevelData,
NewFeatureSupportLevelMap,
useNewFeatureSupportLevel,
} from '../../../../common/components/newFeatureSupportLevels';
import useSupportLevelsAPI from '../../../hooks/useSupportLevelsAPI';

export type NetworkConfigurationProps = VirtualIPControlGroupProps & {
hostSubnets: HostSubnets;
Expand Down Expand Up @@ -74,20 +77,29 @@ const getManagedNetworkingDisabledReason = (
};

const getUserManagedDisabledReason = (
featureSupportLevelData: NewFeatureSupportLevelData,
featureSupportLevelContext: NewFeatureSupportLevelData,
platformType?: PlatformType,
featureSupportLevelMap?: NewFeatureSupportLevelMap | null,
) => {
if (platformType === 'nutanix' || platformType === 'vsphere') {
return 'User-Managed Networking is not supported when using Nutanix or vSphere';
}
if (!featureSupportLevelData.isFeatureSupported('USER_MANAGED_NETWORKING')) {
return featureSupportLevelData.getFeatureDisabledReason('USER_MANAGED_NETWORKING');
if (!featureSupportLevelContext.isFeatureSupported('USER_MANAGED_NETWORKING')) {
return featureSupportLevelContext.getFeatureDisabledReason(
'USER_MANAGED_NETWORKING',
featureSupportLevelMap ?? undefined,
undefined,
platformType,
);
}
};

const getClusterManagedDisabledReason = (featureSupportLevelData: NewFeatureSupportLevelData) => {
if (!featureSupportLevelData.isFeatureSupported('CLUSTER_MANAGED_NETWORKING')) {
return featureSupportLevelData.getFeatureDisabledReason('CLUSTER_MANAGED_NETWORKING');
const getClusterManagedDisabledReason = (
featureSupportLevelContext: NewFeatureSupportLevelData,
featureSupportLevelMap?: NewFeatureSupportLevelMap | null,
) => {
if (!featureSupportLevelContext.isFeatureSupported('CLUSTER_MANAGED_NETWORKING')) {
return featureSupportLevelContext.getFeatureDisabledReason(
'CLUSTER_MANAGED_NETWORKING',
featureSupportLevelMap ?? undefined,
);
}
};

Expand All @@ -96,6 +108,7 @@ const getManagedNetworkingState = (
isOracleCloudInfrastructure: boolean,
featureSupportLevelData: NewFeatureSupportLevelData,
platformType?: PlatformType,
featureSupportLevelMap?: NewFeatureSupportLevelMap | null,
): {
isDisabled: boolean;
clusterManagedDisabledReason?: string;
Expand All @@ -106,8 +119,15 @@ const getManagedNetworkingState = (
isOracleCloudInfrastructure,
featureSupportLevelData,
);
const cmnReason = getClusterManagedDisabledReason(featureSupportLevelData);
const umnReason = getUserManagedDisabledReason(featureSupportLevelData, platformType);
const cmnReason = getClusterManagedDisabledReason(
featureSupportLevelData,
featureSupportLevelMap,
);
const umnReason = getUserManagedDisabledReason(
featureSupportLevelData,
platformType,
featureSupportLevelMap,
);

return {
isDisabled: !!(cmnReason || umnReason || networkingReason),
Expand All @@ -122,7 +142,13 @@ const NetworkConfiguration = ({
isVipDhcpAllocationDisabled,
defaultNetworkSettings,
}: NetworkConfigurationProps) => {
const featureSupportLevelData = useNewFeatureSupportLevel();
const featureSupportLevelContext = useNewFeatureSupportLevel();
const featureSupportLevelData = useSupportLevelsAPI(
'features',
cluster.openshiftVersion,
cluster.cpuArchitecture as CpuArchitecture,
cluster.platform?.type,
);
const { isViewerMode } = useSelector(selectCurrentClusterPermissionsState);
const { setFieldValue, values, validateField } = useFormikContext<NetworkConfigurationValues>();

Expand Down Expand Up @@ -200,10 +226,11 @@ const NetworkConfiguration = ({
getManagedNetworkingState(
isDualStack,
cluster.platform?.type === 'oci',
featureSupportLevelData,
featureSupportLevelContext,
cluster.platform?.type,
featureSupportLevelData,
),
[isDualStack, cluster.platform?.type, featureSupportLevelData],
[isDualStack, cluster.platform?.type, featureSupportLevelContext, featureSupportLevelData],
);

return (
Expand Down Expand Up @@ -249,7 +276,7 @@ const NetworkConfiguration = ({
<VirtualIPControlGroup
cluster={cluster}
isVipDhcpAllocationDisabled={isVipDhcpAllocationDisabled}
supportLevel={featureSupportLevelData.getFeatureSupportLevel('VIP_AUTO_ALLOC')}
supportLevel={featureSupportLevelContext.getFeatureSupportLevel('VIP_AUTO_ALLOC')}
/>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
PlatformType,
} from '../../../common';
import { architectureData } from '../clusterConfiguration/CpuArchitectureDropdown';
import { ExternalPlatformLabels } from '../clusterConfiguration/platformIntegration/constants';

const CNV_OPERATOR_LABEL = 'Openshift Virtualization';
const LVMS_OPERATOR_LABEL = 'Logical Volume Manager Storage';
Expand Down Expand Up @@ -174,7 +175,9 @@ export const getNewFeatureDisabledReason = (
return getNetworkTypeSelectionDisabledReason(cluster);
}
case 'CLUSTER_MANAGED_NETWORKING': {
return 'Cluster-managed networking is not supported for ARM architecture with this version of OpenShift.';
return `Cluster-managed networking is not supported when using ${
platformType ? ExternalPlatformLabels[platformType] : ''
}`;
}
case 'EXTERNAL_PLATFORM_OCI': {
return getOciDisabledReason(cpuArchitecture, isSupported);
Expand All @@ -194,9 +197,11 @@ export const getNewFeatureDisabledReason = (
return `Integration with vSphere is not available with the selected CPU architecture.`;
}
}
case 'PLATFORM_MANAGED_NETWORKING': {
case 'USER_MANAGED_NETWORKING': {
if (!isSupported) {
return `User-Managed Networking is not supported when using ${platformType || ''}`;
return `User-Managed Networking is not supported when using ${
platformType ? ExternalPlatformLabels[platformType] : ''
}`;
}
}
default: {
Expand Down

0 comments on commit aa2af91

Please sign in to comment.