Skip to content

Commit 7f441dc

Browse files
authored
Merge pull request kubernetes#84600 from jsafrane/e2e-log-initcontainers
Grab init containers logs in e2e tests
2 parents 08e5781 + 17307c0 commit 7f441dc

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
@@ -1137,15 +1137,16 @@ func (f *Framework) MatchContainerOutput(
11371137

11381138
if podErr != nil {
11391139
// Pod failed. Dump all logs from all containers to see what's wrong
1140-
for _, container := range podStatus.Spec.Containers {
1141-
logs, err := e2epod.GetPodLogs(f.ClientSet, ns, podStatus.Name, container.Name)
1140+
_ = podutil.VisitContainers(&podStatus.Spec, func(c *v1.Container) bool {
1141+
logs, err := e2epod.GetPodLogs(f.ClientSet, ns, podStatus.Name, c.Name)
11421142
if err != nil {
11431143
Logf("Failed to get logs from node %q pod %q container %q: %v",
1144-
podStatus.Spec.NodeName, podStatus.Name, container.Name, err)
1145-
continue
1144+
podStatus.Spec.NodeName, podStatus.Name, c.Name, err)
1145+
} else {
1146+
Logf("Output of node %q pod %q container %q: %s", podStatus.Spec.NodeName, podStatus.Name, c.Name, logs)
11461147
}
1147-
Logf("Output of node %q pod %q container %q: %s", podStatus.Spec.NodeName, podStatus.Name, container.Name, logs)
1148-
}
1148+
return true
1149+
})
11491150
return fmt.Errorf("expected pod %q success: %v", createdPod.Name, podErr)
11501151
}
11511152

0 commit comments

Comments
 (0)