Add cleanup functions to multiple DB backends. (#2313)
Ensure it's called on unmount, not just for seal.
This commit is contained in:
parent
67410ab230
commit
47274eca88
|
@ -30,6 +30,10 @@ func Backend() *backend {
|
|||
Secrets: []*framework.Secret{
|
||||
secretCreds(&b),
|
||||
},
|
||||
|
||||
Clean: func() {
|
||||
b.ResetDB(nil)
|
||||
},
|
||||
}
|
||||
|
||||
return &b
|
||||
|
|
|
@ -31,6 +31,8 @@ func Backend() *backend {
|
|||
Secrets: []*framework.Secret{
|
||||
secretCreds(&b),
|
||||
},
|
||||
|
||||
Clean: b.ResetDB,
|
||||
}
|
||||
|
||||
return &b
|
||||
|
|
|
@ -31,6 +31,8 @@ func Backend() *backend {
|
|||
Secrets: []*framework.Secret{
|
||||
secretCreds(&b),
|
||||
},
|
||||
|
||||
Clean: b.ResetDB,
|
||||
}
|
||||
|
||||
return &b
|
||||
|
|
|
@ -256,6 +256,12 @@ func (c *Core) unmount(path string) (bool, error) {
|
|||
return true, err
|
||||
}
|
||||
|
||||
// Call cleanup function if it exists
|
||||
b, ok := c.router.root.Get(path)
|
||||
if ok {
|
||||
b.(*routeEntry).backend.Cleanup()
|
||||
}
|
||||
|
||||
// Unmount the backend entirely
|
||||
if err := c.router.Unmount(path); err != nil {
|
||||
return true, err
|
||||
|
@ -271,7 +277,7 @@ func (c *Core) unmount(path string) (bool, error) {
|
|||
return true, err
|
||||
}
|
||||
if c.logger.IsInfo() {
|
||||
c.logger.Info("core: successful unmounted", "path", path)
|
||||
c.logger.Info("core: successfully unmounted", "path", path)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue