Skip to content

Commit 17307c0

Browse files
committed
Grab init containers logs in e2e tests
Storage tests use initContainers + framework.TestContainerOutput and they will benefit from logging their output in failed tests.
1 parent ef479c1 commit 17307c0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test/e2e/framework/util.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,15 +1249,16 @@ func (f *Framework) MatchContainerOutput(
12491249

12501250
if podErr != nil {
12511251
// Pod failed. Dump all logs from all containers to see what's wrong
1252-
for _, container := range podStatus.Spec.Containers {
1253-
logs, err := e2epod.GetPodLogs(f.ClientSet, ns, podStatus.Name, container.Name)
1252+
_ = podutil.VisitContainers(&podStatus.Spec, func(c *v1.Container) bool {
1253+
logs, err := e2epod.GetPodLogs(f.ClientSet, ns, podStatus.Name, c.Name)
12541254
if err != nil {
12551255
Logf("Failed to get logs from node %q pod %q container %q: %v",
1256-
podStatus.Spec.NodeName, podStatus.Name, container.Name, err)
1257-
continue
1256+
podStatus.Spec.NodeName, podStatus.Name, c.Name, err)
1257+
} else {
1258+
Logf("Output of node %q pod %q container %q: %s", podStatus.Spec.NodeName, podStatus.Name, c.Name, logs)
12581259
}
1259-
Logf("Output of node %q pod %q container %q: %s", podStatus.Spec.NodeName, podStatus.Name, container.Name, logs)
1260-
}
1260+
return true
1261+
})
12611262
return fmt.Errorf("expected pod %q success: %v", createdPod.Name, podErr)
12621263
}
12631264

0 commit comments

Comments
 (0)