Skip to content

KAFKA-18948 Move DynamicLogConfig to server module#22353

Open
unknowntpo wants to merge 6 commits into
apache:trunkfrom
unknowntpo:move-dynamic-log-config
Open

KAFKA-18948 Move DynamicLogConfig to server module#22353
unknowntpo wants to merge 6 commits into
apache:trunkfrom
unknowntpo:move-dynamic-log-config

Conversation

@unknowntpo
Copy link
Copy Markdown
Contributor

@unknowntpo unknowntpo commented May 23, 2026

Summary

Move DynamicLogConfig from core to the server module as a Java
BrokerReconfigurable.

This also moves extractLogConfigMap to AbstractKafkaConfig, so log
reconfiguration no longer depends directly on
kafka.server.KafkaConfig.

Note: this branch temporarily includes the generic
BrokerReconfigurable change from #22409 so DynamicLogConfig can use
AbstractKafkaConfig directly. Drop that commit after #22409 is merged.

Testing

  • ./gradlew :core:test --tests kafka.server.DynamicBrokerConfigTest

Reviewers: Ken Huang s7133700@gmail.com, Chia-Ping Tsai
chia7712@gmail.com

@github-actions github-actions Bot added triage PRs from the community core Kafka Broker labels May 23, 2026
@unknowntpo unknowntpo force-pushed the move-dynamic-log-config branch 2 times, most recently from 16d254e to ce74012 Compare May 23, 2026 06:29
@github-actions github-actions Bot added the storage Pull requests that target the storage module label May 23, 2026
Copy link
Copy Markdown
Collaborator

@m1a2st m1a2st left a comment

Choose a reason for hiding this comment

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

Thanks @unknowntpo for this patch!

import java.util.stream.Collectors;
import java.util.stream.Stream;

public class DynamicLogConfig implements BrokerReconfigurable {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should add new test for this new config class.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, DynamicLogConfigTest are added, please take a look, thanks.

@unknowntpo unknowntpo force-pushed the move-dynamic-log-config branch 2 times, most recently from 3732ab0 to ce74012 Compare May 24, 2026 03:42
@github-actions github-actions Bot removed the triage PRs from the community label May 24, 2026
@chia7712 chia7712 changed the title MINOR: Move DynamicLogConfig to server module KAFKA-18948 Move DynamicLogConfig to server module May 24, 2026
logManager.brokerConfigUpdated();
for (UnifiedLog unifiedLog : logManager.allLogs()) {
Map<String, Object> props = new HashMap<>(newBrokerDefaults);
unifiedLog.config().originals().entrySet().stream()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could call forEach directly

unifiedLog.config().originals().forEach((k, v) -> {
    if (unifiedLog.config().overriddenConfigs.contains(k)) {
        props.put(k, v);
    }
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

private void validateLogLocalRetentionMs(AbstractKafkaConfig config) {
long logRetentionMs = config.logRetentionTimeMillis();
long logLocalRetentionMs = config.getLong(RemoteLogManagerConfig.LOG_LOCAL_RETENTION_MS_PROP);
if (logRetentionMs != LogConfig.NO_RETENTION_LIMIT && logLocalRetentionMs != LogConfig.DEFAULT_LOCAL_RETENTION_MS) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I also replaced raw -1 / -2 retention sentinels with LogConfig constants. This keeps DynamicLogConfig aligned with LogConfig semantics and makes the validation easier to read without changing behavior.

@unknowntpo unknowntpo force-pushed the move-dynamic-log-config branch from 8c6f7a1 to d2c8e74 Compare May 25, 2026 08:55
validateCordonedLogDirs(kafkaConfig);
}

private AbstractKafkaConfig requireKafkaConfig(AbstractConfig config) {
Copy link
Copy Markdown
Member

@chia7712 chia7712 May 26, 2026

Choose a reason for hiding this comment

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

Maybe we could add generics to BrokerReconfigurable? For example, BrokerReconfigurable<T extends AbstractConfig>. This would allow both the storage and server modules to access the specific config types they need

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. I don't like the cast either. A generic BrokerReconfigurable<T extends AbstractConfig> sounds like the right direction, but it touches the interface and all implementers, so I will keep this PR focused and
handle that in a follow-up PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I raised a minor PR #22409 for the generic BrokerReconfigurable, and add temporary commits about it to verify if it worked here. I would drop that commit after #22409 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved core Kafka Broker storage Pull requests that target the storage module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants