-
Notifications
You must be signed in to change notification settings - Fork 456
/
crashdump.go
44 lines (34 loc) · 1.09 KB
/
crashdump.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package docker
import (
"context"
"fmt"
"io"
"strings"
"github.com/docker/docker/api/types/container"
"github.com/siderolabs/talos/pkg/provision"
)
// CrashDump produces debug information to help with debugging failures.
func (p *provisioner) CrashDump(ctx context.Context, cluster provision.Cluster, out io.Writer) {
containers, err := p.listNodes(ctx, cluster.Info().ClusterName)
if err != nil {
fmt.Fprintf(out, "error listing containers: %s\n", err)
return
}
for _, ctr := range containers {
name := ctr.Names[0][1:]
fmt.Fprintf(out, "%s\n%s\n\n", name, strings.Repeat("=", len(name)))
logs, err := p.client.ContainerLogs(ctx, ctr.ID, container.LogsOptions{
ShowStdout: true,
ShowStderr: true,
Tail: "1000",
})
if err != nil {
fmt.Fprintf(out, "error querying container logs: %s\n", err)
continue
}
_, _ = io.Copy(out, logs) //nolint:errcheck
}
}