Skip to content

Commit 25afedb

Browse files
committed
CNV-60049: fix interface modal with udn
1 parent d9991ed commit 25afedb

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

src/utils/components/NetworkInterfaceModal/components/hooks/useNADsData.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { useMemo } from 'react';
22

33
import { NetworkAttachmentDefinitionModelGroupVersionKind } from '@kubevirt-ui/kubevirt-api/console';
44
import useNADListPermissions from '@kubevirt-utils/components/NetworkInterfaceModal/components/hooks/useNADListPermissions';
5-
import { getExtraNADResources } from '@kubevirt-utils/components/NetworkInterfaceModal/components/hooks/utils';
6-
import { getName } from '@kubevirt-utils/resources/shared';
7-
import { PRIMARY_UDN_BINDING } from '@kubevirt-utils/resources/vm/utils/network/constants';
5+
import {
6+
filterUDNNads,
7+
getExtraNADResources,
8+
} from '@kubevirt-utils/components/NetworkInterfaceModal/components/hooks/utils';
89
import { isEmpty } from '@kubevirt-utils/utils/utils';
910
import { K8sResourceCommon, useK8sWatchResources } from '@openshift-console/dynamic-plugin-sdk';
1011

@@ -24,9 +25,8 @@ const useNADsData: UseNADsData = (namespace) => {
2425
const accumulatedData = useMemo(() => {
2526
return (Object.values(data) || [])?.reduce(
2627
(acc, nads) => {
27-
const nadsWithNoPrimaryUDNBinding =
28-
nads?.data?.filter((nad) => getName(nad) !== PRIMARY_UDN_BINDING) || [];
29-
acc.nads.push(...nadsWithNoPrimaryUDNBinding);
28+
const availableNADs = filterUDNNads(nads?.data || []);
29+
acc.nads.push(...availableNADs);
3030
acc.loaded = acc.loaded && (!isEmpty(nads?.loadError) || nads?.loaded);
3131
acc.loadError = isEmpty(nads?.loadError) ? acc.loadError : nads?.loadError;
3232
return acc;

src/utils/components/NetworkInterfaceModal/components/hooks/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import {
55
OPENSHIFT_MULTUS_NS,
66
OPENSHIFT_SRIOV_NETWORK_OPERATOR_NS,
77
} from '@kubevirt-utils/constants/constants';
8+
import { getLabel } from '@kubevirt-utils/resources/shared';
9+
import { UDN_LABEL } from '@kubevirt-utils/resources/udn/constants';
810
import { isEmpty } from '@kubevirt-utils/utils/utils';
11+
import { K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk';
912

1013
const resources = {
1114
default: {
@@ -41,3 +44,6 @@ export const getExtraNADResources = (
4144
return newMap;
4245
}, {});
4346
};
47+
48+
export const filterUDNNads = (nads: K8sResourceCommon[]) =>
49+
nads?.filter((nad) => getLabel(nad, UDN_LABEL) === undefined);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export const LAYER2_TOPOLOGY = 'layer2';
22
export const LAYER3_TOPOLOGY = 'layer3';
33
export const LOCALNET_TOPOLOGY = 'localnet';
4+
export const UDN_LABEL = 'k8s.ovn.org/user-defined-network';
45

56
export const PrimaryTopologies = [LAYER2_TOPOLOGY, LAYER3_TOPOLOGY];
67
export const SecondaryTopologies = [LOCALNET_TOPOLOGY];

src/utils/resources/vm/utils/network/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,3 @@ const labels2types: LabelMap = Object.fromEntries(
4343

4444
export const interfaceTypesProxy = new Proxy<TypeMap>(types2labels, typeHandler);
4545
export const interfaceLabelsProxy = new Proxy<LabelMap>(labels2types, labelHandler);
46-
47-
export const PRIMARY_UDN_BINDING = 'primary-udn-kubevirt-binding';

0 commit comments

Comments
 (0)