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

Plugin likely leaks client connections when using multiple secrets across clusters #166

Open
chadlwilson opened this issue Jan 8, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@chadlwilson
Copy link
Member

The current code caches a kubernetes client. Since each secret configured has to configure the cluster details individually it is clearly intended that you have a single Secret and lots of entries within it.

In any case, when the code detects a new client is needed it does not close the old client gracefully.

public synchronized KubernetesClient client(SecretConfig secretConfig) {
if (secretConfig.hasSameTargetCluster(this.secretConfig) && this.client != null) {
LOG.debug("Using previously created client.");
return this.client;
}
LOG.debug(format("Creating a new client because {0}.", (client == null) ? "client is null" : "secret configuration has changed"));
this.secretConfig = secretConfig;
this.client = createClientFor(secretConfig);
LOG.debug("New client is created.");
return this.client;
}

Doing so in the client() method before recreating (which sounds easy) would possibly lead to race conditions since other threads may have just been given the previously cached client and trying to use it.

The change in c4a9338 avoids creating new clients when unnecessary, so this should only happen when pointing it to other clusters or in more obscure situations. Additionally, perhaps okhttp does something to clean up and close idle connections anyway. Not sure - raising it here in case it is confirmed as an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant