diff --git a/cmd/containerd/command/main.go b/cmd/containerd/command/main.go index 9fe4e38924ce8..8251b1eddcb59 100644 --- a/cmd/containerd/command/main.go +++ b/cmd/containerd/command/main.go @@ -25,6 +25,7 @@ import ( "os/signal" "path/filepath" "runtime" + "strings" "time" "github.com/containerd/containerd/errdefs" @@ -314,7 +315,15 @@ func dumpStacks(writeToFile bool) { bufferLen *= 2 } buf = buf[:stackSize] - logrus.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf) + stacks := strings.Split(string(buf), "\n\n") + logrus.WithField("stackCount", len(stacks)).Info("Begin goroutine stack dump") + for i, stack := range stacks { + logrus.WithFields(logrus.Fields{ + "index": i, + "stack": stack, + }).Info("Dumping goroutine stack") + } + logrus.Info("End goroutine stack dump") if writeToFile { // Also write to file to aid gathering diagnostics