From 04a3f698003cfea381af9a3def9c0c495fcde0a2 Mon Sep 17 00:00:00 2001 From: Sebastian Sch Date: Thu, 31 Mar 2022 13:41:53 +0300 Subject: [PATCH] Fix the validation webhook for virtual environments Signed-off-by: Sebastian Sch --- deploy/configmap.yaml | 2 +- deployment/sriov-network-operator/templates/configmap.yaml | 2 +- pkg/webhook/validate.go | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/deploy/configmap.yaml b/deploy/configmap.yaml index 8a32c77b1..3e447432b 100644 --- a/deploy/configmap.yaml +++ b/deploy/configmap.yaml @@ -21,4 +21,4 @@ data: Broadcom_bnxt_BCM57414_2x25G: "14e4 16d7 16dc" Broadcom_bnxt_BCM75508_2x100G: "14e4 1750 1806" Qlogic_qede_QL45000_50G: "1077 1654 1664" - + Red_Hat_Virtio_network_device: "1af4 1000 1000" diff --git a/deployment/sriov-network-operator/templates/configmap.yaml b/deployment/sriov-network-operator/templates/configmap.yaml index 8a32c77b1..3e447432b 100644 --- a/deployment/sriov-network-operator/templates/configmap.yaml +++ b/deployment/sriov-network-operator/templates/configmap.yaml @@ -21,4 +21,4 @@ data: Broadcom_bnxt_BCM57414_2x25G: "14e4 16d7 16dc" Broadcom_bnxt_BCM75508_2x100G: "14e4 1750 1806" Qlogic_qede_QL45000_50G: "1077 1654 1664" - + Red_Hat_Virtio_network_device: "1af4 1000 1000" diff --git a/pkg/webhook/validate.go b/pkg/webhook/validate.go index 09119cbf5..4c86fd4e7 100644 --- a/pkg/webhook/validate.go +++ b/pkg/webhook/validate.go @@ -297,8 +297,11 @@ func validateNicModel(selector *sriovnetworkv1.SriovNetworkNicSelector, iface *s return true } + // Check the vendor and device ID of the VF only if we are on a virtual environment for key := range utils.PlatformMap { - if strings.Contains(strings.ToLower(node.Spec.ProviderID), strings.ToLower(key)) && sriovnetworkv1.IsVfSupportedModel(iface.Vendor, iface.DeviceID) { + if strings.Contains(strings.ToLower(node.Spec.ProviderID), strings.ToLower(key)) && + selector.NetFilter != "" && selector.NetFilter == iface.NetFilter && + sriovnetworkv1.IsVfSupportedModel(iface.Vendor, iface.DeviceID) { return true } }