Skip to content

Commit

Permalink
plugin: fix process leak when Setup() fails (#9557)
Browse files Browse the repository at this point in the history
We've noticed some leftover processes from vault plugins on our boxes. Some
of them were even left over from previous instances of the service and reparented
to init.  This could cause issues if too many of them accumulate.

When running with TRACE logging the logs showed that there was an error return by
the call to Setup() the plugin. Looking through the code it looks like we do not
call Cleanup() in that case.

Co-authored-by: Sorin Dumitru <[email protected]>
  • Loading branch information
2 people authored and ncabatoff committed Jul 22, 2020
1 parent aff6589 commit 3d1275e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions builtin/plugin/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func Backend(ctx context.Context, conf *logical.BackendConfig) (logical.Backend,
}
err = raw.Setup(ctx, conf)
if err != nil {
raw.Cleanup(ctx)
return nil, err
}
// Get SpecialPaths and BackendType
Expand Down Expand Up @@ -108,6 +109,7 @@ func (b *PluginBackend) startBackend(ctx context.Context, storage logical.Storag
}
err = nb.Setup(ctx, b.config)
if err != nil {
nb.Cleanup(ctx)
return err
}

Expand Down

0 comments on commit 3d1275e

Please sign in to comment.