diff --git a/cnf-certification-test/networking/icmp/icmp.go b/cnf-certification-test/networking/icmp/icmp.go index e477034a21..54e727275d 100644 --- a/cnf-certification-test/networking/icmp/icmp.go +++ b/cnf-certification-test/networking/icmp/icmp.go @@ -63,10 +63,7 @@ func BuildNetTestContext(pods []*provider.Pod, aIPVersion netcommons.IPVersion, } for netKey, multusNetworkInterface := range put.MultusNetworkInterfaces { // The first container is used to get the network namespace - // Loop through all the network interfaces and their IPs - for _, networkInterface := range multusNetworkInterface { - processContainerIpsPerNet(put.Containers[0], netKey, networkInterface.IPs, networkInterface.Interface, netsUnderTest, aIPVersion, logger) - } + processContainerIpsPerNet(put.Containers[0], netKey, multusNetworkInterface.IPs, multusNetworkInterface.Interface, netsUnderTest, aIPVersion, logger) } continue } diff --git a/cnf-certification-test/networking/icmp/icmp_test.go b/cnf-certification-test/networking/icmp/icmp_test.go index fb1e3c7485..d0aa6663ea 100644 --- a/cnf-certification-test/networking/icmp/icmp_test.go +++ b/cnf-certification-test/networking/icmp/icmp_test.go @@ -523,7 +523,7 @@ func TestBuildNetTestContext(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { for idx := range tt.args.pods { - tt.args.pods[idx].MultusNetworkInterfaces = make(map[string][]provider.CniNetworkInterface) + tt.args.pods[idx].MultusNetworkInterfaces = make(map[string]provider.CniNetworkInterface) var err error tt.args.pods[idx].MultusNetworkInterfaces, err = provider.GetPodIPsPerNet(tt.args.pods[idx].GetAnnotations()[provider.CniNetworksStatusKey]) if err != nil { @@ -572,20 +572,16 @@ var ( }, }, }, - MultusNetworkInterfaces: map[string][]provider.CniNetworkInterface{ + MultusNetworkInterfaces: map[string]provider.CniNetworkInterface{ "tnf/mynet-ipv4-0": { - { - Interface: "net1", - Name: "mynet-ipv4-0", - IPs: []string{"192.168.0.3"}, - }, + Interface: "net1", + Name: "mynet-ipv4-0", + IPs: []string{"192.168.0.3"}, }, "tnf/mynet-ipv4-1": { - { - Interface: "net2", - Name: "mynet-ipv4-1", - IPs: []string{"192.168.1.3"}, - }, + Interface: "net2", + Name: "mynet-ipv4-1", + IPs: []string{"192.168.1.3"}, }, }, SkipNetTests: false, @@ -623,20 +619,16 @@ var ( }, }, }, - MultusNetworkInterfaces: map[string][]provider.CniNetworkInterface{ + MultusNetworkInterfaces: map[string]provider.CniNetworkInterface{ "tnf/mynet-ipv4-0": { - { - Interface: "net1", - Name: "mynet-ipv4-0", - IPs: []string{"192.168.0.4"}, - }, + Interface: "net1", + Name: "mynet-ipv4-0", + IPs: []string{"192.168.0.4"}, }, "tnf/mynet-ipv4-1": { - { - Interface: "net2", - Name: "mynet-ipv4-1", - IPs: []string{"192.168.1.4"}, - }, + Interface: "net2", + Name: "mynet-ipv4-1", + IPs: []string{"192.168.1.4"}, }, }, SkipNetTests: false, @@ -674,7 +666,7 @@ var ( }, }, }, - MultusNetworkInterfaces: map[string][]provider.CniNetworkInterface{ + MultusNetworkInterfaces: map[string]provider.CniNetworkInterface{ "": {}, }, SkipNetTests: true, @@ -712,7 +704,7 @@ var ( }, }, }, - MultusNetworkInterfaces: map[string][]provider.CniNetworkInterface{ + MultusNetworkInterfaces: map[string]provider.CniNetworkInterface{ "": {}, }, SkipNetTests: false, diff --git a/pkg/provider/pods.go b/pkg/provider/pods.go index 9033e153e7..dfef2fa484 100644 --- a/pkg/provider/pods.go +++ b/pkg/provider/pods.go @@ -43,7 +43,7 @@ const ( type Pod struct { *corev1.Pod Containers []*Container - MultusNetworkInterfaces map[string][]CniNetworkInterface + MultusNetworkInterfaces map[string]CniNetworkInterface MultusPCIs []string SkipNetTests bool SkipMultusNetTests bool @@ -52,7 +52,7 @@ type Pod struct { func NewPod(aPod *corev1.Pod) (out Pod) { var err error out.Pod = aPod - out.MultusNetworkInterfaces = make(map[string][]CniNetworkInterface) + out.MultusNetworkInterfaces = make(map[string]CniNetworkInterface) out.MultusNetworkInterfaces, err = GetPodIPsPerNet(aPod.GetAnnotations()[CniNetworksStatusKey]) if err != nil { log.Error("Could not get IPs for Pod %q (namespace %q), err: %v", aPod.Name, aPod.Namespace, err) diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index f75b9fefdd..66d48135e4 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -447,11 +447,11 @@ func GetRuntimeUID(cs *corev1.ContainerStatus) (runtime, uid string) { // GetPodIPsPerNet gets the IPs of a pod. // CNI annotation "k8s.v1.cni.cncf.io/networks-status". // Returns (ips, error). -func GetPodIPsPerNet(annotation string) (ips map[string][]CniNetworkInterface, err error) { +func GetPodIPsPerNet(annotation string) (ips map[string]CniNetworkInterface, err error) { // This is a map indexed with the network name (network attachment) and // listing all the IPs created in this subnet and belonging to the pod namespace // The list of ips pr net is parsed from the content of the "k8s.v1.cni.cncf.io/networks-status" annotation. - ips = make(map[string][]CniNetworkInterface) + ips = make(map[string]CniNetworkInterface) var cniInfo []CniNetworkInterface err = json.Unmarshal([]byte(annotation), &cniInfo) @@ -462,7 +462,7 @@ func GetPodIPsPerNet(annotation string) (ips map[string][]CniNetworkInterface, e // Otherwise add all non default interfaces for _, cniInterface := range cniInfo { if !cniInterface.Default { - ips[cniInterface.Name] = append(ips[cniInterface.Name], cniInterface) + ips[cniInterface.Name] = cniInterface } } return ips, nil