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

secret/database: ensure plugins are closed if they cannot be initialized #3768

Merged
merged 1 commit into from
Jan 9, 2018

Conversation

briankassouf
Copy link
Contributor

No description provided.

@briankassouf briankassouf requested review from jefferai and calvn January 9, 2018 20:13
@calvn
Copy link
Contributor

calvn commented Jan 9, 2018

Shouldn't we call Database.Close() on Initialize errors for builtin database plugins as well?

func (dc *DatabasePluginClient) Initialize(ctx context.Context, config map[string]interface{}, verifyConnection bool) error {
err := dc.Database.Initialize(ctx, config, verifyConnection)
if err != nil {
dc.Close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database object in here might be nil if verify_connection was set to false (thus never calling Connection() to instantiate the object). dc.Close() -> dc.Database.Close() would be called on a nil db if the Initialize error comes from something else (e.g. https://github.com/hashicorp/vault/blob/master/plugins/helper/database/connutil/sql.go#L58).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that something that should be handled by the Close() implementation in the database though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, missed that. It's all good here!

@briankassouf briankassouf merged commit 05f2030 into master Jan 9, 2018
@briankassouf briankassouf deleted the fix-plugin-leak branch January 9, 2018 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants