Skip to content

getClientConfiguration bean should be annotated with @ConditionalOnMissingBean #3407

@benkeil

Description

@benkeil

Problem

OperatorAutoConfiguration.getClientConfiguration() is not annotated with @ConditionalOnMissingBean, unlike the kubernetesClient() bean which is correctly guarded.

This means getClientConfiguration() is always executed, even when a custom KubernetesClient bean is already provided (e.g. in tests via a local K3s cluster).
The method calls Config.autoConfigure() or new ConfigBuilder() internally, both of which read ~/.kube/config and attempt to resolve all exec-credentials — including expired ones (e.g. expired gcloud tokens) — even if they are completely irrelevant for the current context.

Expected behavior

getClientConfiguration() should be annotated with @ConditionalOnMissingBean(Config.class) so that it can be skipped when a custom Config bean is provided, consistent with how kubernetesClient() is handled.

Suggested fix

@Bean
@ConditionalOnMissingBean(Config.class)  // <-- add this
public Config getClientConfiguration(
    @Autowired(required = false) KubernetesConfigCustomizer configCustomizer) {
    ...
}

Context

Version: 6.4.1
Module: operator-framework-spring-boot-starter
In test environments using e.g. K3sTestAutoConfiguration (which provides its own KubernetesClient bean via @ConditionalOnMissingBean), the getClientConfiguration() method still always fires and causes warnings/errors due to stale credentials in ~/.kube/config, even though the resulting Config bean is never actually used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions