Skip to content

Commit

Permalink
[VAULT-708] Zero out request counter on preSeal (#11970)
Browse files Browse the repository at this point in the history
* [VAULT-708] Zero out request counter on preSeal

* [VAULT-708] Added changelog entry

* [VAULT-708] Add comment clarifying request counter zeroing
  • Loading branch information
pmmukh authored Jul 7, 2021
1 parent b282ca8 commit 6b8e4dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog/11970.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core: Fixed double counting of http requests after operator stepdown
```
6 changes: 6 additions & 0 deletions vault/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 6b8e4dc

Please sign in to comment.