Skip to content

fix: use class-based logger name in BaseConfigurationService.#3352

Merged
csviri merged 1 commit into
operator-framework:mainfrom
Dennis-Mircea:fix/base-configuration-service-logger-name
May 15, 2026
Merged

fix: use class-based logger name in BaseConfigurationService.#3352
csviri merged 1 commit into
operator-framework:mainfrom
Dennis-Mircea:fix/base-configuration-service-logger-name

Conversation

@Dennis-Mircea
Copy link
Copy Markdown
Contributor

Summary

BaseConfigurationService is the only class in operator-framework-core / operator-framework main sources that creates its SLF4J logger from a hard-coded string rather than from getClass() / Class.class:

private static final String LOGGER_NAME = "Default ConfigurationService implementation";
private static final Logger logger = LoggerFactory.getLogger(LOGGER_NAME);

That produces log lines like:

2026-05-11 14:52:16,844 Default ConfigurationService implementation [INFO ] Created configuration for reconciler org.apache.flink.kubernetes.operator.controller.FlinkDeploymentController with name flinkdeploymentcontroller

…which looks like a status message rather than a logger name when consumed by downstream operators (observed via Apache Flink Kubernetes Operator) and breaks the common %logger / %c pattern most logback / log4j configurations rely on for filtering and routing.

The literal string has been in place since 2021 (introduced in 10998f18 "feat: log when a configuration is not found or created automatically") and has been the only such case for the entire time, so this looks like a stray inconsistency rather than an intentional choice.

This PR aligns BaseConfigurationService with the rest of the codebase by deriving the logger name from the class:

private static final Logger logger = LoggerFactory.getLogger(BaseConfigurationService.class);

The public getLoggerName() method is preserved and now returns logger.getName(), so the API still works and stays consistent with whatever the logger is actually configured with.

Behavior change to be aware of

This does change the logger name as it appears in log output and in the value returned by BaseConfigurationService#getLoggerName():

  • Before: Default ConfigurationService implementation
  • After: io.javaoperatorsdk.operator.api.config.BaseConfigurationService

If any consumer has logback / log4j filters, appenders, or log-routing rules keyed on the old literal string, those configurations will need to be updated to the FQCN (or a prefix match against io.javaoperatorsdk.operator.api.config). Worth a brief mention in the release notes.

Test plan

  • ./mvnw -pl operator-framework-core -am compile - succeeds, no new warnings.
  • ./mvnw -pl operator-framework-core -am test -Dtest=ConfigurationServiceOverriderTest - passes (2/2).
  • Spotless / license check pass for the touched module.

Copilot AI review requested due to automatic review settings May 15, 2026 10:14
@openshift-ci openshift-ci Bot requested review from metacosm and xstefank May 15, 2026 10:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the logging configuration of BaseConfigurationService to use a class-based logger and aligns getLoggerName() with the logger instance.

Changes:

  • Replace the string-named SLF4J logger with a class-based logger (BaseConfigurationService.class).
  • Update getLoggerName() to return the current logger’s name rather than a hardcoded constant.


private static final String LOGGER_NAME = "Default ConfigurationService implementation";
private static final Logger logger = LoggerFactory.getLogger(LOGGER_NAME);
private static final Logger logger = LoggerFactory.getLogger(BaseConfigurationService.class);
@SuppressWarnings("unused")
public String getLoggerName() {
return LOGGER_NAME;
return logger.getName();
Signed-off-by: Dennis-Mircea Ciupitu <dennis.mircea.ciupitu@gmail.com>
@Dennis-Mircea Dennis-Mircea force-pushed the fix/base-configuration-service-logger-name branch from 26ea5a3 to bc448c6 Compare May 15, 2026 10:19
@metacosm
Copy link
Copy Markdown
Collaborator

I don't recall why we made this implementation choice at the time but we should look into it before merging this.

Copy link
Copy Markdown
Collaborator

@csviri csviri left a comment

Choose a reason for hiding this comment

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

I don't recall it either, but since it is quite old commit, probably some leftover that we did not notice yet. So from my side this can go in.

Thank you! @Dennis-Mircea

@csviri
Copy link
Copy Markdown
Collaborator

csviri commented May 15, 2026

Maybe double check Quarkus side @metacosm @xstefank. Thank you!

@csviri csviri merged commit 0c89520 into operator-framework:main May 15, 2026
27 checks passed
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.

5 participants