Skip to content

Commit 9837f5d

Browse files
committed
Fix pods cleanup in ClusterUserDefinedNetwork test
netConfig pointer was being modified in a loop so pods were removed from only one namespace. Signed-off-by: Patryk Diak <[email protected]>
1 parent e356b61 commit 9837f5d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/extended/networking/network_segmentation.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,6 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User
395395
namespaceRed := f.Namespace.Name + "-" + red
396396
namespaceBlue := f.Namespace.Name + "-" + blue
397397

398-
netConfig := &networkAttachmentConfigParams{
399-
topology: topology,
400-
cidr: correctCIDRFamily(oc, userDefinedv4Subnet, userDefinedv6Subnet),
401-
role: "primary",
402-
}
403398
for _, namespace := range []string{namespaceRed, namespaceBlue} {
404399
By("Creating namespace " + namespace)
405400
_, err := cs.CoreV1().Namespaces().Create(context.Background(), &v1.Namespace{
@@ -409,6 +404,7 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User
409404
}, metav1.CreateOptions{})
410405
Expect(err).NotTo(HaveOccurred())
411406
defer func() {
407+
By("Removing namespace " + namespace)
412408
Expect(cs.CoreV1().Namespaces().Delete(
413409
context.Background(),
414410
namespace,
@@ -419,8 +415,13 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User
419415
networkNamespaceMap := map[string]string{namespaceRed: red, namespaceBlue: blue}
420416
for namespace, network := range networkNamespaceMap {
421417
By("creating the network " + network + " in namespace " + namespace)
422-
netConfig.namespace = namespace
423-
netConfig.name = network
418+
netConfig := &networkAttachmentConfigParams{
419+
topology: topology,
420+
cidr: correctCIDRFamily(oc, userDefinedv4Subnet, userDefinedv6Subnet),
421+
role: "primary",
422+
namespace: namespace,
423+
name: network,
424+
}
424425

425426
Expect(createNetworkFn(netConfig)).To(Succeed())
426427
// update the name because createNetworkFn may mutate the netConfig.name
@@ -582,7 +583,7 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User
582583
cleanup, err := createManifest("", cudnManifest)
583584
DeferCleanup(func() {
584585
cleanup()
585-
By("delete pods in test namespace to unblock CUDN CR & associate NAD deletion")
586+
By(fmt.Sprintf("delete pods in %s namespace to unblock CUDN CR & associate NAD deletion", c.namespace))
586587
Expect(cs.CoreV1().Pods(c.namespace).DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{})).To(Succeed())
587588
_, err := e2ekubectl.RunKubectl("", "delete", "clusteruserdefinednetwork", cudnName, "--wait", fmt.Sprintf("--timeout=%ds", 120))
588589
Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)