Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of Don't rely on post-unseal funcs being run in any particular order. into release/1.13.x #22369

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
File renamed without changes.
3 changes: 3 additions & 0 deletions changelog/22362.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core: Fix readonly errors that could occur while loading mounts/auths during unseal
```
7 changes: 3 additions & 4 deletions vault/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,10 +795,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
Expand Down Expand Up @@ -911,6 +907,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 {
Expand Down
7 changes: 3 additions & 4 deletions vault/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -1484,10 +1484,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
Expand Down Expand Up @@ -1573,6 +1569,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 {
Expand Down