From adbaad17dba5cdf1e259953f3f7b6a851095e45d Mon Sep 17 00:00:00 2001 From: Pratyoy Mukhopadhyay <35388175+pmmukh@users.noreply.github.com> Date: Wed, 7 Jul 2021 14:03:39 -0500 Subject: [PATCH] [VAULT-708] Zero out request counter on preSeal (#11970) * [VAULT-708] Zero out request counter on preSeal * [VAULT-708] Added changelog entry * [VAULT-708] Add comment clarifying request counter zeroing --- changelog/11970.txt | 3 +++ vault/core.go | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 changelog/11970.txt diff --git a/changelog/11970.txt b/changelog/11970.txt new file mode 100644 index 000000000..60ea438b0 --- /dev/null +++ b/changelog/11970.txt @@ -0,0 +1,3 @@ +```release-note:bug +core: Fixed double counting of http requests after operator stepdown +``` \ No newline at end of file diff --git a/vault/core.go b/vault/core.go index 55dbbfc6b..3b6e461fd 100644 --- a/vault/core.go +++ b/vault/core.go @@ -2183,6 +2183,12 @@ func (c *Core) preSeal() error { if err := c.unloadMounts(context.Background()); err != nil { result = multierror.Append(result, fmt.Errorf("error unloading mounts: %w", err)) } + + // Zeros out the requests counter to avoid sending all requests for the month on stepdown + // when this runs on the active node. Unseal does the complementary operation of loading + // the counter from storage, so this operation should be a safe one. + atomic.StoreUint64(c.counters.requests, 0) + if err := enterprisePreSeal(c); err != nil { result = multierror.Append(result, err) }