Skip to content

KubernetesClientConfiguration is not thread-safe #1436

@PSanetra

Description

@PSanetra

Describe the bug
KubernetesClientConfiguration is mutated by the Kubernetes.Dispose() Method as the Kubernetes constructor just copies the reference to the SslCaCerts property and Kubernetes.Dispose() disposes that collection, which is actually coming from the KubernetesClientConfiguration instance.

See

CaCerts = config.SslCaCerts;

And
// Dispose the certificates
if (CaCerts is not null)
{
foreach (var caCert in CaCerts)
{
caCert.Dispose();
}
CaCerts.Clear();
}

Kubernetes C# SDK Client Version
12.1.1

Server Kubernetes Version
v1.27.3

Dotnet Runtime Version
net7

To Reproduce

  • Load a KubernetesClientConfiguration instance which contains SslCaCerts entries
  • Pass that instance to the Kubernetes constructor
  • Dispose the Kubernetes instance
  • Check the KuberenetesClientConfiguration.SSlCaCerts collection
    • The collection is now empty

Expected behavior
The KubernetesClientConfiguration should not be modified. Maybe expose a Dispose method on the KubernetesClientConfiguration to dispose the CaCerts.

Alternatively document explicitly that a KubernetesClientConfiguration can be used only by exactly on Kubernetes instance and must be abandoned after passing it to a single Kubernetes constructor.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions