Skip to content

Commit 7718d06

Browse files
author
John Howard
committed
Write stack dump to os.TempDir() as well
Signed-off-by: John Howard <[email protected]>
1 parent b819d05 commit 7718d06

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cmd/containerd/command/main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,14 @@ func dumpStacks() {
291291
}
292292
buf = buf[:stackSize]
293293
logrus.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf)
294+
295+
// Also write to file to aid gathering diagnostics
296+
name := filepath.Join(os.TempDir(), fmt.Sprintf("containerd.%d.stacks.log", os.Getpid()))
297+
f, err := os.Create(name)
298+
if err != nil {
299+
return
300+
}
301+
defer f.Close()
302+
f.WriteString(string(buf))
303+
logrus.Infof("goroutine stack dump written to %s", name)
294304
}

0 commit comments

Comments
 (0)