Skip to content

KAFKA-20337: Make all GroupConfig fields Optional and clean up validation#22003

Merged
chia7712 merged 1 commit intoapache:trunkfrom
dajac:KAFKA-20337-optional-group-config
Apr 9, 2026
Merged

KAFKA-20337: Make all GroupConfig fields Optional and clean up validation#22003
chia7712 merged 1 commit intoapache:trunkfrom
dajac:KAFKA-20337-optional-group-config

Conversation

@dajac
Copy link
Copy Markdown
Member

@dajac dajac commented Apr 8, 2026

All GroupConfig fields are now Optional, storing only explicitly
provided values. Broker-level defaults are resolved at access time via
flatMap().orElse(brokerDefault), eliminating stale-capture issues when
broker configs change dynamically.

Key changes:

  • All 21 GroupConfig fields are private Optional, using
    optionalInt/Boolean/String helpers based on originals().
  • GroupConfigManager no longer needs a defaultConfig; constructor
    simplified.
  • GroupCoordinatorConfig.extractGroupConfigMap(ShareGroupConfig)
    removed.
  • All consumers (GroupMetadataManager, ShareGroupConfigProvider,
    KafkaApis) use flatMap.
  • validateValues refactored with validateIntRange/Max/Min helpers
    operating on a single filtered parsed map.
  • Cross-field checks use broker defaults for missing values.

Reviewers: Sean Quah squah@confluent.io, Chia-Ping Tsai
chia7712@gmail.com

@dajac
Copy link
Copy Markdown
Member Author

dajac commented Apr 8, 2026

@squah-confluent I have been playing with those dynamic configs and I came up with this patch. Please take a look.

Copy link
Copy Markdown
Contributor

@squah-confluent squah-confluent left a comment

Choose a reason for hiding this comment

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

Thanks for the refactor, looks good!

The approach to validate() where we only pass in the present parsed values is nice.

@dajac dajac force-pushed the KAFKA-20337-optional-group-config branch from 96c26ce to 1e55293 Compare April 9, 2026 08:43
@dajac dajac requested a review from squah-confluent April 9, 2026 09:52
Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@dajac this is indeed a excellent refactor. two small comments left. PTAL

@@ -2828,7 +2828,8 @@ class KafkaApis(val requestChannel: RequestChannel,
} else {
// Compute group-specific timeout for caching errors (2 * heartbeat interval)
val heartbeatIntervalMs = Option(groupConfigManager.groupConfig(streamsGroupHeartbeatRequest.data.groupId).orElse(null))
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.

              val heartbeatIntervalMs = groupConfigManager.groupConfig(streamsGroupHeartbeatRequest.data.groupId)
                .flatMap[java.lang.Integer](gc => gc.streamsHeartbeatIntervalMs())
                .orElseGet(() => config.groupCoordinatorConfig.streamsGroupHeartbeatIntervalMs())
                .toLong

@@ -324,48 +314,41 @@ public static Optional<String> brokerSynonym(String groupConfigName) {

public GroupConfig(Map<?, ?> props) {
super(CONFIG_DEF, props, false);
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.

Have you considered dropping the AbstractConfig inheritance entirely? Since we now expect callers to strictly use the new Optional getter methods, extending AbstractConfig unnecessarily exposes a wider, unsafe API surface.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, I have. At the moment, AbstractConfig's methods are used by ConfigHelper so I stopped here in this PR. I will investigate this further as follow-ups.

…tion

All GroupConfig fields are now Optional<T>, storing only explicitly
provided values. Broker-level defaults are resolved at access time via
flatMap().orElse(brokerDefault), eliminating stale-capture issues when
broker configs change dynamically.

Key changes:
- All 21 GroupConfig fields are private Optional, using
  optionalInt/Boolean/String helpers based on originals().
- GroupConfigManager no longer needs a defaultConfig; constructor
  simplified.
- GroupCoordinatorConfig.extractGroupConfigMap(ShareGroupConfig)
  removed.
- All consumers (GroupMetadataManager, ShareGroupConfigProvider,
  KafkaApis) use flatMap.
- validate() uses CONFIG_DEF.parse() directly instead of constructing
  a GroupConfig, keeping validation independent from GroupConfig
  construction.
- validateValues refactored with validateIntRange/Max/Min helpers
  operating on a single filtered parsed map.
- Cross-field checks use broker defaults for missing values.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dajac dajac force-pushed the KAFKA-20337-optional-group-config branch from 1e55293 to 5f29cef Compare April 9, 2026 11:52
@dajac dajac requested a review from chia7712 April 9, 2026 15:24
@chia7712 chia7712 merged commit e4cd243 into apache:trunk Apr 9, 2026
24 checks passed
@dajac dajac deleted the KAFKA-20337-optional-group-config branch April 9, 2026 17:01
nileshkumar3 pushed a commit to nileshkumar3/kafka that referenced this pull request Apr 15, 2026
…ion (apache#22003)

All GroupConfig fields are now Optional<T>, storing only explicitly
provided values. Broker-level defaults are resolved at access time via
flatMap().orElse(brokerDefault), eliminating stale-capture issues when
broker configs change dynamically.

Key changes:
- All 21 GroupConfig fields are private Optional, using
optionalInt/Boolean/String helpers based on originals().
- GroupConfigManager no longer needs a defaultConfig; constructor
simplified.
- GroupCoordinatorConfig.extractGroupConfigMap(ShareGroupConfig)
removed.
- All consumers (GroupMetadataManager, ShareGroupConfigProvider,
KafkaApis) use flatMap.
- validateValues refactored with validateIntRange/Max/Min helpers
operating on a single filtered parsed map.
- Cross-field checks use broker defaults for missing values.

Reviewers: Sean Quah <squah@confluent.io>, Chia-Ping Tsai
 <chia7712@gmail.com>

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants