diff --git a/api/v1/sriovnetworknodepolicy_types.go b/api/v1/sriovnetworknodepolicy_types.go index 3646ec719f..cacc62cc92 100644 --- a/api/v1/sriovnetworknodepolicy_types.go +++ b/api/v1/sriovnetworknodepolicy_types.go @@ -57,6 +57,8 @@ type SriovNetworkNodePolicySpec struct { // +kubebuilder:validation:Enum=virtio // VDPA device type. Allowed value "virtio" VdpaType string `json:"vdpaType,omitempty"` + // Exclude device's NUMA node when advertising this resource. Default to false. + ExcludeNUMATopology bool `json:"excludeTopology,omitempty"` } type SriovNetworkNicSelector struct { diff --git a/config/crd/bases/sriovnetwork.openshift.io_sriovnetworknodepolicies.yaml b/config/crd/bases/sriovnetwork.openshift.io_sriovnetworknodepolicies.yaml index 34224cd837..ccf1c860a3 100644 --- a/config/crd/bases/sriovnetwork.openshift.io_sriovnetworknodepolicies.yaml +++ b/config/crd/bases/sriovnetwork.openshift.io_sriovnetworknodepolicies.yaml @@ -49,6 +49,10 @@ spec: - legacy - switchdev type: string + excludeTopology: + description: Exclude device's NUMA node when advertising this resource. + Default to false. + type: boolean isRdma: description: RDMA mode. Defaults to false. type: boolean diff --git a/controllers/sriovnetworknodepolicy_controller.go b/controllers/sriovnetworknodepolicy_controller.go index 6627f08bf0..17738c5bc2 100644 --- a/controllers/sriovnetworknodepolicy_controller.go +++ b/controllers/sriovnetworknodepolicy_controller.go @@ -689,6 +689,8 @@ func createDevicePluginResource( rawNetDeviceSelectors := json.RawMessage(netDeviceSelectorsMarshal) rc.Selectors = &rawNetDeviceSelectors + rc.ExcludeTopology = p.Spec.ExcludeNUMATopology + return rc, nil } @@ -758,5 +760,7 @@ func updateDevicePluginResource( rawNetDeviceSelectors := json.RawMessage(netDeviceSelectorsMarshal) rc.Selectors = &rawNetDeviceSelectors + rc.ExcludeTopology = p.Spec.ExcludeNUMATopology + return nil } diff --git a/controllers/sriovnetworknodepolicy_controller_test.go b/controllers/sriovnetworknodepolicy_controller_test.go index 5c4beeb97c..2762cdd0e1 100644 --- a/controllers/sriovnetworknodepolicy_controller_test.go +++ b/controllers/sriovnetworknodepolicy_controller_test.go @@ -171,6 +171,24 @@ func TestRenderDevicePluginConfigData(t *testing.T) { }, }, }, + { + tname: "testExcludeNUMATopology", + policy: sriovnetworkv1.SriovNetworkNodePolicy{ + Spec: v1.SriovNetworkNodePolicySpec{ + ResourceName: "resourceName", + ExcludeNUMATopology: true, + }, + }, + expResource: dptypes.ResourceConfList{ + ResourceList: []dptypes.ResourceConfig{ + { + ResourceName: "resourceName", + Selectors: mustMarshallSelector(t, &dptypes.NetDeviceSelectors{}), + ExcludeTopology: true, + }, + }, + }, + }, } reconciler := SriovNetworkNodePolicyReconciler{} diff --git a/deployment/sriov-network-operator/crds/sriovnetwork.openshift.io_sriovnetworknodepolicies.yaml b/deployment/sriov-network-operator/crds/sriovnetwork.openshift.io_sriovnetworknodepolicies.yaml index 34224cd837..ccf1c860a3 100644 --- a/deployment/sriov-network-operator/crds/sriovnetwork.openshift.io_sriovnetworknodepolicies.yaml +++ b/deployment/sriov-network-operator/crds/sriovnetwork.openshift.io_sriovnetworknodepolicies.yaml @@ -49,6 +49,10 @@ spec: - legacy - switchdev type: string + excludeTopology: + description: Exclude device's NUMA node when advertising this resource. + Default to false. + type: boolean isRdma: description: RDMA mode. Defaults to false. type: boolean