Merge pull request #3190 from jhowardmsft/jjh/stack2file

Write stack dump to `os.TempDir()` as well
This commit is contained in:
Phil Estes 2019-04-18 14:43:25 -04:00 committed by GitHub
commit ffe0b6927b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -291,4 +291,14 @@ func dumpStacks() {
}
buf = buf[:stackSize]
logrus.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf)
// Also write to file to aid gathering diagnostics
name := filepath.Join(os.TempDir(), fmt.Sprintf("containerd.%d.stacks.log", os.Getpid()))
f, err := os.Create(name)
if err != nil {
return
}
defer f.Close()
f.WriteString(string(buf))
logrus.Infof("goroutine stack dump written to %s", name)
}