mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
Protect part of emitMetrics from panic behavior during post-seal (#10708)
* vault/core_metrics.go * changelog * comments
This commit is contained in:
3
changelog/10708.txt
Normal file
3
changelog/10708.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
metrics: Protect emitMetrics from panicking during post-seal
|
||||||
|
```
|
||||||
@@ -259,6 +259,13 @@ func (c *Core) findKvMounts() []*kvMount {
|
|||||||
c.mountsLock.RLock()
|
c.mountsLock.RLock()
|
||||||
defer c.mountsLock.RUnlock()
|
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 {
|
for _, entry := range c.mounts.Entries {
|
||||||
if entry.Type == "kv" {
|
if entry.Type == "kv" {
|
||||||
version, ok := entry.Options["version"]
|
version, ok := entry.Options["version"]
|
||||||
|
|||||||
Reference in New Issue
Block a user