From c10ccf1c1cc80a83c525176b827322d25f75e7b6 Mon Sep 17 00:00:00 2001 From: hc-github-team-secure-vault-core <82990506+hc-github-team-secure-vault-core@users.noreply.github.com> Date: Wed, 24 Aug 2022 16:00:37 -0400 Subject: [PATCH] backport of commit a222dbfd2954bf2f41e27fb96f4d9be2347504f7 (#16852) Co-authored-by: davidadeleon <56207066+davidadeleon@users.noreply.github.com> --- 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 000000000000..70c7d341b605 --- /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 0dd0fbf13a42..f0a8846939bd 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