Grab init containers logs in e2e tests

Storage tests use initContainers + framework.TestContainerOutput and they
will benefit from logging their output in failed tests.
This commit is contained in:
Jan Safranek 2019-10-31 14:58:51 +01:00
parent ef479c1a6f
commit 17307c055c

View File

@ -1249,15 +1249,16 @@ func (f *Framework) MatchContainerOutput(
if podErr != nil {
// Pod failed. Dump all logs from all containers to see what's wrong
for _, container := range podStatus.Spec.Containers {
logs, err := e2epod.GetPodLogs(f.ClientSet, ns, podStatus.Name, container.Name)
_ = podutil.VisitContainers(&podStatus.Spec, func(c *v1.Container) bool {
logs, err := e2epod.GetPodLogs(f.ClientSet, ns, podStatus.Name, c.Name)
if err != nil {
Logf("Failed to get logs from node %q pod %q container %q: %v",
podStatus.Spec.NodeName, podStatus.Name, container.Name, err)
continue
podStatus.Spec.NodeName, podStatus.Name, c.Name, err)
} else {
Logf("Output of node %q pod %q container %q: %s", podStatus.Spec.NodeName, podStatus.Name, c.Name, logs)
}
Logf("Output of node %q pod %q container %q: %s", podStatus.Spec.NodeName, podStatus.Name, container.Name, logs)
}
return true
})
return fmt.Errorf("expected pod %q success: %v", createdPod.Name, podErr)
}