From 6690ec9590088d15ffa5e0df002c6355a15f2918 Mon Sep 17 00:00:00 2001 From: davemay99 Date: Sun, 6 Jun 2021 00:32:38 -0400 Subject: [PATCH] Add remaining pprof profiles to debug dump --- command/operator_debug.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/command/operator_debug.go b/command/operator_debug.go index a66d3ff24de..4dc87decf9b 100644 --- a/command/operator_debug.go +++ b/command/operator_debug.go @@ -674,6 +674,12 @@ func (c *OperatorDebugCommand) collectPprof(path, id string, client *api.Client) } } + err = c.savePprofProfile(path, "heap", opts, client) + err = c.savePprofProfile(path, "allocs", opts, client) + err = c.savePprofProfile(path, "threadcreate", opts, client) + err = c.savePprofProfile(path, "block", opts, client) + err = c.savePprofProfile(path, "mutex", opts, client) + // Gather goroutine text output - debug type 1 // debug type 1 writes the legacy text format for human readable output opts.Debug = 1 @@ -702,6 +708,19 @@ func (c *OperatorDebugCommand) collectPprof(path, id string, client *api.Client) } } +// savePprofProfile collects a pprof profile from the client API and writes to disk +func (c *OperatorDebugCommand) savePprofProfile(path string, profile string, opts api.PprofOptions, client *api.Client) error { + bs, err := client.Agent().Lookup(profile, opts, nil) + if err != nil { + return fmt.Errorf("%s: Failed to retrieve pprof profile %s, err: %v", path, profile, err) + } + + fileName := fmt.Sprintf("%s.prof", profile) + err = c.writeBytes(path, fileName, bs) + + return err +} + // collectPeriodic runs for duration, capturing the cluster state every interval. It flushes and stops // the monitor requests func (c *OperatorDebugCommand) collectPeriodic(client *api.Client) {