Skip to content

Commit e801779

Browse files
committed
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 "<podName>-container" as container name and "<podName>-" 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.
1 parent 36e40fb commit e801779

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/e2e/network/network_policy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ func checkConnectivity(f *framework.Framework, ns *v1.Namespace, podClient *v1.P
14151415
err = e2epod.WaitForPodSuccessInNamespace(f.ClientSet, podClient.Name, ns.Name)
14161416
if err != nil {
14171417
// Collect pod logs when we see a failure.
1418-
logs, logErr := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podClient.Name, fmt.Sprintf("%s-container", podClient.Name))
1418+
logs, logErr := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podClient.Name, "client")
14191419
if logErr != nil {
14201420
framework.Failf("Error getting container logs: %s", logErr)
14211421
}
@@ -1452,7 +1452,7 @@ func checkNoConnectivity(f *framework.Framework, ns *v1.Namespace, podClient *v1
14521452
// Dump debug information if the error was nil.
14531453
if err == nil {
14541454
// Collect pod logs when we see a failure.
1455-
logs, logErr := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podClient.Name, fmt.Sprintf("%s-container", podClient.Name))
1455+
logs, logErr := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podClient.Name, "client")
14561456
if logErr != nil {
14571457
framework.Failf("Error getting container logs: %s", logErr)
14581458
}
@@ -1589,7 +1589,7 @@ func createNetworkClientPod(f *framework.Framework, namespace *v1.Namespace, pod
15891589
RestartPolicy: v1.RestartPolicyNever,
15901590
Containers: []v1.Container{
15911591
{
1592-
Name: fmt.Sprintf("%s-container", podName),
1592+
Name: "client",
15931593
Image: imageutils.GetE2EImage(imageutils.BusyBox),
15941594
Args: []string{
15951595
"/bin/sh",

0 commit comments

Comments
 (0)