mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 18:02:01 +00:00
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.
This commit is contained in:
parent
36e40fb850
commit
e8017795d1
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user