Merge pull request #111015 from xmcqueen/master

Capture the Container Logs for a Flaky Test
This commit is contained in:
Kubernetes Prow Robot 2022-07-11 16:58:50 -07:00 committed by GitHub
commit a455c296fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,12 +126,30 @@ var _ = SIGDescribe("Node Performance Testing [Serial] [Slow]", func() {
// Create the pod.
pod = f.PodClient().CreateSync(pod)
// Wait for pod success.
f.PodClient().WaitForSuccess(pod.Name, wl.Timeout())
// but avoid using WaitForSuccess because we want the container logs upon failure #109295
podErr := e2epod.WaitForPodCondition(f.ClientSet, f.Namespace.Name, pod.Name, fmt.Sprintf("%s or %s", v1.PodSucceeded, v1.PodFailed), wl.Timeout(),
func(pod *v1.Pod) (bool, error) {
switch pod.Status.Phase {
case v1.PodFailed:
return true, fmt.Errorf("pod %q failed with reason: %q, message: %q", pod.Name, pod.Status.Reason, pod.Status.Message)
case v1.PodSucceeded:
return true, nil
default:
return false, nil
}
},
)
podLogs, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, pod.Name, pod.Spec.Containers[0].Name)
framework.ExpectNoError(err)
if podErr != nil {
framework.Logf("dumping pod logs due to pod error detected: \n%s", podLogs)
framework.Failf("pod error: %v", podErr)
}
perf, err := wl.ExtractPerformanceFromLogs(podLogs)
framework.ExpectNoError(err)
framework.Logf("Time to complete workload %s: %v", wl.Name(), perf)
// using framework.ExpectNoError for consistency would cause changes the output format
gomega.Expect(podErr).To(gomega.Succeed(), "wait for pod %q to succeed", pod.Name)
}
ginkgo.BeforeEach(func() {