From 592949d7ba221d3a89f533bf42eeaf6200c2d241 Mon Sep 17 00:00:00 2001 From: davidadeleon <56207066+davidadeleon@users.noreply.github.com> Date: Tue, 23 Aug 2022 17:09:30 -0400 Subject: [PATCH] command/debug: fix bug where monitor was not honoring configured duration (#16834) * Use specific client with longer timeout for log debug target * add changelog * update changelog entry --- changelog/16834.txt | 3 +++ command/debug.go | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 changelog/16834.txt diff --git a/changelog/16834.txt b/changelog/16834.txt new file mode 100644 index 000000000..70c7d341b --- /dev/null +++ b/changelog/16834.txt @@ -0,0 +1,3 @@ +```release-note:bug +command/debug: fix bug where monitor was not honoring configured duration +``` \ No newline at end of file diff --git a/command/debug.go b/command/debug.go index 8213507cd..71e1a97c8 100644 --- a/command/debug.go +++ b/command/debug.go @@ -1071,7 +1071,18 @@ func (c *DebugCommand) writeLogs(ctx context.Context) { } defer out.Close() - logCh, err := c.cachedClient.Sys().Monitor(ctx, "trace", c.logFormat) + // Create Monitor specific client based on the cached client + mClient, err := c.cachedClient.Clone() + if err != nil { + c.captureError("log", err) + return + } + mClient.SetToken(c.cachedClient.Token()) + + // Set timeout to match the context explicitly + mClient.SetClientTimeout(c.flagDuration + debugDurationGrace) + + logCh, err := mClient.Sys().Monitor(ctx, "trace", c.logFormat) if err != nil { c.captureError("log", err) return