Fixes multiplexed plugin initialization after manual plugin reload (#17248)

* Fixes initialize not called after v5 plugin reload

* use request context instead of core activeContext
This commit is contained in:
Austin Gebauer 2022-09-22 10:16:21 -07:00 committed by GitHub
parent 5477fd86fa
commit a6139cd5b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -8,7 +8,6 @@ import (
"sync"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/go-uuid"
v5 "github.com/hashicorp/vault/builtin/plugin/v5"

View File

@ -213,6 +213,15 @@ func (c *Core) reloadBackendCommon(ctx context.Context, entry *MountEntry, isAut
re.backend = backend
if backend != nil {
// Initialize the backend after reload. This is a no-op for backends < v5 which
// rely on lazy loading for initialization. v5 backends do not rely on lazy loading
// for initialization unless the plugin process is killed. Reload of a v5 backend
// results in a new plugin process, so we must initialize the backend here.
err := backend.Initialize(ctx, &logical.InitializationRequest{Storage: view})
if err != nil {
return err
}
// Set paths as well
paths := backend.SpecialPaths()
if paths != nil {