From 29886fb9781392cdcb93b37a90419bcd0acb00d9 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Thu, 8 Jun 2017 14:08:49 -0700 Subject: [PATCH] daemon: Remove daemon datastructure dump functionality When sending SIGUSR1 to the daemon, it can crash because of a concurrent map access panic, showing a stack trace involving dumpDaemon. It appears it's not possible to recover from a concurrent map access panic. Since it's important that SIGUSR1 not be a destructive operation, sadly the best course of action I can think of is to remove this functionality. Signed-off-by: Aaron Lehmann Upstream-commit: a4c68ee8574c9b8a3309ebebee0d90108042ba61 Component: engine --- components/engine/daemon/debugtrap.go | 62 ------------------- components/engine/daemon/debugtrap_unix.go | 6 -- components/engine/daemon/debugtrap_windows.go | 6 -- 3 files changed, 74 deletions(-) delete mode 100644 components/engine/daemon/debugtrap.go diff --git a/components/engine/daemon/debugtrap.go b/components/engine/daemon/debugtrap.go deleted file mode 100644 index 209048b589..0000000000 --- a/components/engine/daemon/debugtrap.go +++ /dev/null @@ -1,62 +0,0 @@ -package daemon - -import ( - "fmt" - "os" - "path/filepath" - "strings" - "time" - - "github.com/davecgh/go-spew/spew" - "github.com/pkg/errors" -) - -const dataStructuresLogNameTemplate = "daemon-data-%s.log" - -// dumpDaemon appends the daemon datastructures into file in dir and returns full path -// to that file. -func (d *Daemon) dumpDaemon(dir string) (string, error) { - // Ensure we recover from a panic as we are doing this without any locking - defer func() { - recover() - }() - - path := filepath.Join(dir, fmt.Sprintf(dataStructuresLogNameTemplate, strings.Replace(time.Now().Format(time.RFC3339), ":", "", -1))) - f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0666) - if err != nil { - return "", errors.Wrap(err, "failed to open file to write the daemon datastructure dump") - } - defer f.Close() - - dump := struct { - containers interface{} - names interface{} - links interface{} - execs interface{} - volumes interface{} - images interface{} - layers interface{} - imageReferences interface{} - downloads interface{} - uploads interface{} - registry interface{} - plugins interface{} - }{ - containers: d.containers, - execs: d.execCommands, - volumes: d.volumes, - images: d.imageStore, - layers: d.layerStore, - imageReferences: d.referenceStore, - downloads: d.downloadManager, - uploads: d.uploadManager, - registry: d.RegistryService, - plugins: d.PluginStore, - names: d.nameIndex, - links: d.linkIndex, - } - - spew.Fdump(f, dump) // Does not return an error - f.Sync() - return path, nil -} diff --git a/components/engine/daemon/debugtrap_unix.go b/components/engine/daemon/debugtrap_unix.go index d650eb7f8c..8605d1d2b5 100644 --- a/components/engine/daemon/debugtrap_unix.go +++ b/components/engine/daemon/debugtrap_unix.go @@ -22,12 +22,6 @@ func (d *Daemon) setupDumpStackTrap(root string) { } else { logrus.Infof("goroutine stacks written to %s", path) } - path, err = d.dumpDaemon(root) - if err != nil { - logrus.WithError(err).Error("failed to write daemon datastructure dump") - } else { - logrus.Infof("daemon datastructure dump written to %s", path) - } } }() } diff --git a/components/engine/daemon/debugtrap_windows.go b/components/engine/daemon/debugtrap_windows.go index fb20c9d2c5..d01f7f332d 100644 --- a/components/engine/daemon/debugtrap_windows.go +++ b/components/engine/daemon/debugtrap_windows.go @@ -41,12 +41,6 @@ func (d *Daemon) setupDumpStackTrap(root string) { } else { logrus.Infof("goroutine stacks written to %s", path) } - path, err = d.dumpDaemon(root) - if err != nil { - logrus.WithError(err).Error("failed to write daemon datastructure dump") - } else { - logrus.Infof("daemon datastructure dump written to %s", path) - } } }() }