From e8017795d16b40258f3e97379c47399e0a3d438f Mon Sep 17 00:00:00 2001 From: Quan Tian Date: Wed, 4 Dec 2019 17:03:58 +0800 Subject: [PATCH] Fix GetPodLogs failures in NetworkPolicy e2e tests GetPodLogs always fails when the tests fail, which is because the tests specify wrong container names when getting logs. When creating a client Pod, it specifies "-container" as container name and "-" as Pod GenerateName. For instance, podName "client-a" will result in "client-a-container" as the container name and "client-a-vx5sv" as the actual Pod name, but it always uses the actual Pod name to construct the container name when getting logs, e.g. "client-a-vx5sv-container". This patch fixes it by specifying the same static container name when creating Pod and getting logs. --- test/e2e/network/network_policy.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/network/network_policy.go b/test/e2e/network/network_policy.go index c0b9e70fc05..29f7946fae4 100644 --- a/test/e2e/network/network_policy.go +++ b/test/e2e/network/network_policy.go @@ -1415,7 +1415,7 @@ func checkConnectivity(f *framework.Framework, ns *v1.Namespace, podClient *v1.P err = e2epod.WaitForPodSuccessInNamespace(f.ClientSet, podClient.Name, ns.Name) if err != nil { // Collect pod logs when we see a failure. - logs, logErr := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podClient.Name, fmt.Sprintf("%s-container", podClient.Name)) + logs, logErr := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podClient.Name, "client") if logErr != nil { framework.Failf("Error getting container logs: %s", logErr) } @@ -1452,7 +1452,7 @@ func checkNoConnectivity(f *framework.Framework, ns *v1.Namespace, podClient *v1 // Dump debug information if the error was nil. if err == nil { // Collect pod logs when we see a failure. - logs, logErr := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podClient.Name, fmt.Sprintf("%s-container", podClient.Name)) + logs, logErr := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podClient.Name, "client") if logErr != nil { framework.Failf("Error getting container logs: %s", logErr) } @@ -1589,7 +1589,7 @@ func createNetworkClientPod(f *framework.Framework, namespace *v1.Namespace, pod RestartPolicy: v1.RestartPolicyNever, Containers: []v1.Container{ { - Name: fmt.Sprintf("%s-container", podName), + Name: "client", Image: imageutils.GetE2EImage(imageutils.BusyBox), Args: []string{ "/bin/sh",