From 1e0b834c8dc457bd1ada9889786b880c1fe3d10f Mon Sep 17 00:00:00 2001 From: Brandon Palm Date: Thu, 7 Nov 2024 11:43:22 -0600 Subject: [PATCH] search all namespaces for Sriov/NetworkNodePolicy objects --- pkg/autodiscover/autodiscover.go | 12 ++++++++++++ pkg/provider/pods.go | 6 +++--- pkg/provider/provider.go | 4 ++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pkg/autodiscover/autodiscover.go b/pkg/autodiscover/autodiscover.go index 7cbb15c95..e4c438228 100644 --- a/pkg/autodiscover/autodiscover.go +++ b/pkg/autodiscover/autodiscover.go @@ -79,6 +79,8 @@ type DiscoveredTestData struct { AllPackageManifests []*olmPkgv1.PackageManifest SriovNetworks []sriovNetworkOp.SriovNetwork SriovNetworkNodePolicies []sriovNetworkOp.SriovNetworkNodePolicy + AllSriovNetworks []sriovNetworkOp.SriovNetwork + AllSriovNetworkNodePolicies []sriovNetworkOp.SriovNetworkNodePolicy NetworkAttachmentDefinitions []nadClient.NetworkAttachmentDefinition Deployments []appsv1.Deployment StatefulSet []appsv1.StatefulSet @@ -280,6 +282,16 @@ func DoAutoDiscover(config *configuration.TestConfiguration) DiscoveredTestData log.Fatal("Cannot get list of sriov network node policies, err: %v", err) } + data.AllSriovNetworks, err = getSriovNetworks(oc, data.AllNamespaces) + if err != nil { + log.Fatal("Cannot get list of sriov networks, err: %v", err) + } + + data.AllSriovNetworkNodePolicies, err = getSriovNetworkNodePolicies(oc, data.AllNamespaces) + if err != nil { + log.Fatal("Cannot get list of sriov network node policies, err: %v", err) + } + data.NetworkAttachmentDefinitions, err = getNetworkAttachmentDefinitions(oc, data.Namespaces) if err != nil { log.Fatal("Cannot get list of network attachment definitions, err: %v", err) diff --git a/pkg/provider/pods.go b/pkg/provider/pods.go index 5babd9c25..6f244f32b 100644 --- a/pkg/provider/pods.go +++ b/pkg/provider/pods.go @@ -513,9 +513,9 @@ func (p *Pod) IsUsingSRIOVWithMTU() (bool, error) { // If the network-status annotation is not set, let's check the SriovNetwork/SriovNetworkNodePolicy CRs // to see if the MTU is set there. - log.Debug("Number of SriovNetworks: %d", len(env.SriovNetworks)) - log.Debug("Number of SriovNetworkNodePolicies: %d", len(env.SriovNetworkNodePolicies)) - if sriovNetworkUsesMTU(env.SriovNetworks, env.SriovNetworkNodePolicies, nad.Name) { + log.Debug("Number of SriovNetworks: %d", len(env.AllSriovNetworks)) + log.Debug("Number of SriovNetworkNodePolicies: %d", len(env.AllSriovNetworkNodePolicies)) + if sriovNetworkUsesMTU(env.AllSriovNetworks, env.AllSriovNetworkNodePolicies, nad.Name) { return true, nil } } diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index 820c6997c..d3b0143db 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -121,7 +121,9 @@ type TestEnvironment struct { // rename this with testTarget AllPackageManifests []*olmpkgv1.PackageManifest `json:"AllPackageManifests"` OperatorGroups []*olmv1.OperatorGroup `json:"OperatorGroups"` SriovNetworks []sriovNetworkOp.SriovNetwork + AllSriovNetworks []sriovNetworkOp.SriovNetwork SriovNetworkNodePolicies []sriovNetworkOp.SriovNetworkNodePolicy + AllSriovNetworkNodePolicies []sriovNetworkOp.SriovNetworkNodePolicy NetworkAttachmentDefinitions []nadClient.NetworkAttachmentDefinition IstioServiceMeshFound bool ValidProtocolNames []string @@ -359,6 +361,8 @@ func buildTestEnvironment() { //nolint:funlen // SR-IOV env.SriovNetworks = data.SriovNetworks env.SriovNetworkNodePolicies = data.SriovNetworkNodePolicies + env.AllSriovNetworks = data.AllSriovNetworks + env.AllSriovNetworkNodePolicies = data.AllSriovNetworkNodePolicies env.NetworkAttachmentDefinitions = data.NetworkAttachmentDefinitions for _, pod := range env.Pods { isCreatedByDeploymentConfig, err := pod.CreatedByDeploymentConfig()