secrets/database: fixes external plugin reconnect after shutdown for v4 and v5 interface (#12087)

* secrets/database: fixes external plugin shutdown reconnect for v5 interface

* adds changelog entry

* fixes handling of plugin shutdown for password generation on v4 interface
This commit is contained in:
Austin Gebauer 2021-07-15 13:41:04 -07:00 committed by GitHub
parent 03788bdba2
commit d1c090fe63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

View File

@ -315,7 +315,7 @@ func (b *databaseBackend) clearConnection(name string) error {
func (b *databaseBackend) CloseIfShutdown(db *dbPluginInstance, err error) { func (b *databaseBackend) CloseIfShutdown(db *dbPluginInstance, err error) {
// Plugin has shutdown, close it so next call can reconnect. // Plugin has shutdown, close it so next call can reconnect.
switch err { switch err {
case rpc.ErrShutdown, v4.ErrPluginShutdown: case rpc.ErrShutdown, v4.ErrPluginShutdown, v5.ErrPluginShutdown:
// Put this in a goroutine so that requests can run with the read or write lock // Put this in a goroutine so that requests can run with the read or write lock
// and simply defer the unlock. Since we are attaching the instance and matching // and simply defer the unlock. Since we are attaching the instance and matching
// the id in the connection map, we can safely do this. // the id in the connection map, we can safely do this.

View File

@ -92,6 +92,7 @@ func (b *databaseBackend) pathCredsCreateRead() framework.OperationFunc {
password, err := dbi.database.GeneratePassword(ctx, b.System(), dbConfig.PasswordPolicy) password, err := dbi.database.GeneratePassword(ctx, b.System(), dbConfig.PasswordPolicy)
if err != nil { if err != nil {
b.CloseIfShutdown(dbi, err)
return nil, fmt.Errorf("unable to generate password: %w", err) return nil, fmt.Errorf("unable to generate password: %w", err)
} }

3
changelog/12087.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
secrets/database: Fixed an issue that prevented external database plugin processes from restarting after a shutdown.
```