mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
Don't rely on post-unseal funcs being run in any particular order. (#22362)
This commit is contained in:
3
changelog/22362.txt
Normal file
3
changelog/22362.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
core: Fix readonly errors that could occur while loading mounts/auths during unseal
|
||||
```
|
||||
@@ -798,10 +798,6 @@ func (c *Core) setupCredentials(ctx context.Context) error {
|
||||
view.setReadOnlyErr(logical.ErrSetupReadOnly)
|
||||
if strutil.StrListContains(singletonMounts, entry.Type) {
|
||||
defer view.setReadOnlyErr(origViewReadOnlyErr)
|
||||
} else {
|
||||
c.postUnsealFuncs = append(c.postUnsealFuncs, func() {
|
||||
view.setReadOnlyErr(origViewReadOnlyErr)
|
||||
})
|
||||
}
|
||||
|
||||
// Initialize the backend
|
||||
@@ -914,6 +910,9 @@ func (c *Core) setupCredentials(ctx context.Context) error {
|
||||
postUnsealLogger.Error("skipping initialization for nil auth backend")
|
||||
return
|
||||
}
|
||||
if !strutil.StrListContains(singletonMounts, localEntry.Type) {
|
||||
view.setReadOnlyErr(origViewReadOnlyErr)
|
||||
}
|
||||
|
||||
err := backend.Initialize(ctx, &logical.InitializationRequest{Storage: view})
|
||||
if err != nil {
|
||||
|
||||
@@ -1514,10 +1514,6 @@ func (c *Core) setupMounts(ctx context.Context) error {
|
||||
view.setReadOnlyErr(logical.ErrSetupReadOnly)
|
||||
if strutil.StrListContains(singletonMounts, entry.Type) {
|
||||
defer view.setReadOnlyErr(origReadOnlyErr)
|
||||
} else {
|
||||
c.postUnsealFuncs = append(c.postUnsealFuncs, func() {
|
||||
view.setReadOnlyErr(origReadOnlyErr)
|
||||
})
|
||||
}
|
||||
|
||||
var backend logical.Backend
|
||||
@@ -1603,6 +1599,9 @@ func (c *Core) setupMounts(ctx context.Context) error {
|
||||
postUnsealLogger.Error("skipping initialization for nil backend", "path", localEntry.Path)
|
||||
return
|
||||
}
|
||||
if !strutil.StrListContains(singletonMounts, localEntry.Type) {
|
||||
view.setReadOnlyErr(origReadOnlyErr)
|
||||
}
|
||||
|
||||
err := backend.Initialize(ctx, &logical.InitializationRequest{Storage: view})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user