majialoong commented on code in PR #21633:
URL: https://github.com/apache/kafka/pull/21633#discussion_r2925722063


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:
##########
@@ -347,15 +352,182 @@ private static void validateValues(Map<?, ?> valueMaps, 
GroupCoordinatorConfig g
     }
 
     /**
-     * Check that the given properties contain only valid consumer group 
config names and that all values can be
-     * parsed and are valid.
+     * Check that the given properties contain only valid group config names 
and that
+     * all values can be parsed and are valid. The provided properties are 
merged with
+     * the broker-level defaults before validation.
      */
     public static void validate(Properties props, GroupCoordinatorConfig 
groupCoordinatorConfig, ShareGroupConfig shareGroupConfig) {
-        validateNames(props);
-        Map<?, ?> valueMaps = CONFIG.parse(props);
+        Properties combinedConfigs = new Properties();
+        
combinedConfigs.putAll(groupCoordinatorConfig.extractGroupConfigMap(shareGroupConfig));
+        combinedConfigs.putAll(props);
+
+        validateNames(combinedConfigs);
+        Map<?, ?> valueMaps = CONFIG.parse(combinedConfigs);
         validateValues(valueMaps, groupCoordinatorConfig, shareGroupConfig);
     }
 
+    /**
+     * Evaluate group config values to their effective values within 
broker-level bounds.
+     * Out-of-range values are capped and a WARN log is emitted.
+     *
+     * @param props                  The raw group config properties.
+     * @param groupId                The group id.
+     * @param groupCoordinatorConfig The group coordinator config.
+     * @param shareGroupConfig       The share group config.
+     * @return A new Properties with out-of-range values capped.
+     */
+    public static Properties evaluate(
+        Properties props,
+        String groupId,
+        GroupCoordinatorConfig groupCoordinatorConfig,
+        ShareGroupConfig shareGroupConfig
+    ) {
+        Properties effective = new Properties();
+        effective.putAll(props);
+        evaluateValues(effective, groupId, groupCoordinatorConfig, 
shareGroupConfig);
+        return effective;
+    }
+
+    private static void evaluateValues(

Review Comment:
   Thanks for flagging this!
   
   I think the two layers serve different purposes. The `ConfigDef atLeast(N)` 
validators define the inherent lower bound of the parameter itself — for 
example, `atLeast(1)` for session timeout, since a non-positive timeout makes 
no physical sense. The dynamic min/max, on the other hand, defines the 
broker-level policy bounds that an admin can adjust at runtime.
   
   Since the static lower bound reflects a fixed semantic constraint rather 
than a tunable policy, the risk of them drifting out of sync is very low in 
practice.
   
   Let me know if you think there's a cleaner way to structure this — always 
happy to revisit!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to