Skip to content

Commit

Permalink
Merge pull request #2065 from JoshVanL/e2e-include-logs-previous
Browse files Browse the repository at this point in the history
Include previous logs and use all containers from pods
  • Loading branch information
jetstack-bot committed Sep 12, 2019
2 parents 87fbfeb + 6a362c6 commit ab5ddbf
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions test/e2e/framework/addon/chart/addon.go
Expand Up @@ -265,25 +265,33 @@ func (c *Chart) Logs() (map[string]string, error) {

out := make(map[string]string)
for _, pod := range podList {
// Only grab logs from the first container in the pod
// TODO: grab logs from all containers
containerName := pod.Spec.Containers[0].Name
resp := kc.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &corev1.PodLogOptions{
Container: containerName,
}).Do()

err := resp.Error()
if err != nil {
continue
for _, con := range pod.Spec.Containers {
for _, b := range []bool{true, false} {
resp := kc.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &corev1.PodLogOptions{
Container: con.Name,
Previous: b,
}).Do()

err := resp.Error()
if err != nil {
continue
}

logs, err := resp.Raw()
if err != nil {
continue
}

outPath := path.Join(c.Namespace,
fmt.Sprintf("%s-%s", pod.Name, con.Name))

if b {
outPath = fmt.Sprintf("%s-previous", outPath)
}

out[outPath] = string(logs)
}
}

logs, err := resp.Raw()
if err != nil {
continue
}

outPath := path.Join(c.Namespace, pod.Name)
out[outPath] = string(logs)
}

return out, nil
Expand Down

0 comments on commit ab5ddbf

Please sign in to comment.