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

Fix panic if there is a plugin configuration error in the server #3166

Merged
merged 2 commits into from Jun 17, 2022

Conversation

amartinezfayo
Copy link
Member

There is a deferred function in the server's catalog.Load func that calls repo.Close().
The problem is that this could be called before the catalog could be loaded (which can happen when there is an error).

I'm removing this deferred call since we already do that call here: https://github.com/spiffe/spire/blob/main/pkg/server/server.go#L107-L111 (as we do in the agent).

Signed-off-by: Agustín Martínez Fayó <amartinezfayo@gmail.com>
@@ -122,11 +122,6 @@ func Load(ctx context.Context, config Config) (_ *Repository, err error) {
repo := &Repository{
log: config.Log,
}
defer func() {
Copy link
Member

Choose a reason for hiding this comment

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

I think the correct behavior here is to keep the defer and instead change the Close() method to test if the dataStoreCloser and catalogClosers are set before trying to close them individually. This defer cleans up and closes the datastore connection on configuration error.

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my first fix, but then I thought that was redundant. Thanks for pointing the reason, now I see the point.

Signed-off-by: Agustín Martínez Fayó <amartinezfayo@gmail.com>
Copy link
Member

@azdagron azdagron left a comment

Choose a reason for hiding this comment

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

\o/

@azdagron azdagron merged commit 910fdf2 into spiffe:main Jun 17, 2022
@amartinezfayo amartinezfayo deleted the fix-server-plugin-config-panic branch March 1, 2023 18:01
stevend-uber pushed a commit to stevend-uber/spire that referenced this pull request Oct 16, 2023
…ffe#3166)

Signed-off-by: Agustín Martínez Fayó <amartinezfayo@gmail.com>
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.

None yet

2 participants