Skip to content

Commit

Permalink
port (#10729)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hridoy Roy authored Jan 19, 2021
1 parent 7a7d30a commit 9b7b2f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog/10708.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
metrics: Protect emitMetrics from panicking during post-seal
```
7 changes: 7 additions & 0 deletions vault/core_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ func (c *Core) findKvMounts() []*kvMount {
c.mountsLock.RLock()
defer c.mountsLock.RUnlock()

// emitMetrics doesn't grab the statelock, so this code might run during or after the seal process.
// Therefore, we need to check if c.mounts is nil. If we do not, emitMetrics will panic if this is
// run after seal.
if c.mounts == nil {
return mounts
}

for _, entry := range c.mounts.Entries {
if entry.Type == "kv" {
version, ok := entry.Options["version"]
Expand Down

0 comments on commit 9b7b2f5

Please sign in to comment.