You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "gabriellefu (via GitHub)" <gi...@apache.org> on 2026/05/05 17:36:59 UTC

[PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

gabriellefu opened a new pull request, #22213:
URL: https://github.com/apache/kafka/pull/22213

   Adding all the plumb using for rack.aware assignment


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3228916833


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2140,11 +2141,16 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
         }
 
         // Prepare the response.
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");
+        List<String> rackAwareAssignmentTags = rackAwareTagsValue.isEmpty()
+            ? Collections.emptyList()
+            : Arrays.asList(rackAwareTagsValue.split(",", -1));
         StreamsGroupHeartbeatResponseData response = new StreamsGroupHeartbeatResponseData()
             .setMemberId(updatedMember.memberId())
             .setMemberEpoch(updatedMember.memberEpoch())
             .setHeartbeatIntervalMs(streamsGroupHeartbeatIntervalMs(groupId))
-            .setTaskOffsetIntervalMs(streamsGroupTaskOffsetIntervalMs(groupId));
+            .setTaskOffsetIntervalMs(streamsGroupTaskOffsetIntervalMs(groupId))
+            .setRackAwareAssignmentTags(rackAwareAssignmentTags);

Review Comment:
   same as the former comment.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3417468280


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2206,6 +2207,25 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");

Review Comment:
   @lucasbru -- Wondering why `currentAssignmentConfigs` is `Map<String, String>`? Would be convenient here, if the values would be properly typed, so we don't have to parse the tag-list here? Atm, we would parse it on every heartbeat..



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3202821850


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:
##########
@@ -292,6 +298,11 @@ public final class GroupConfig extends AbstractConfig {
             atLeast(0),
             MEDIUM,
             GroupCoordinatorConfig.STREAMS_GROUP_NUM_WARMUP_REPLICAS_DOC)
+        .define(STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG,
+            LIST,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DEFAULT,
+            MEDIUM,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DOC)

Review Comment:
   I was considering the same thing, but in the end the assignment will be the base on the intersection of group.streams.rack.aware.assignment.tags and the tags each clients have, so I think it will just avoid this situation since "" will not be a config that the clients have
   



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3574798501


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:
##########
@@ -297,6 +303,12 @@ public final class GroupConfig extends AbstractConfig {
             atLeast(0),
             MEDIUM,
             GroupCoordinatorConfig.STREAMS_GROUP_NUM_WARMUP_REPLICAS_DOC)
+        .define(STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG,
+            LIST,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DEFAULT,
+            ConfigDef.ValidList.anyNonDuplicateValues(true, false),
+            MEDIUM,

Review Comment:
   I think this should be LOW, as it is LOW in `StreamsConfig`, too.
   
   We are just cleaning up these importance levels: https://github.com/apache/kafka/pull/22541 \cc @suzhiking -- I think we did agree on LOW for this one, right?



##########
docs/getting-started/upgrade.md:
##########
@@ -99,6 +99,7 @@ Note: Apache Kafka 4.2 only supports KRaft mode - ZooKeeper mode has been remove
 
 ### Notable changes in 4.2.0
 
+

Review Comment:
   ?
   
   Not sure if we need to update this file? This feature is not large enough for the top-level upgrade guide IMHO.
   
   However, we could add something to `docs/streams/upgrade-guide.md` to report progress on KIP-1071?



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2354,6 +2357,27 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");
+        // The MISSING_CLIENT_TAGS status (code 6) requires version 1 of the RPC: version 0 clients
+        // throw on unknown status codes, so it must not be sent to them.
+        if (requestApiVersion >= 1 && !rackAwareTagsValue.isEmpty()) {
+            List<String> requiredTags = Arrays.asList(rackAwareTagsValue.split(",", -1));

Review Comment:
   ```suggestion
               List<String> requiredTags = Arrays.asList(rackAwareTagsValue.split("\\s*,\\s*", -1));
   ```



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2354,6 +2357,27 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");
+        // The MISSING_CLIENT_TAGS status (code 6) requires version 1 of the RPC: version 0 clients
+        // throw on unknown status codes, so it must not be sent to them.
+        if (requestApiVersion >= 1 && !rackAwareTagsValue.isEmpty()) {
+            List<String> requiredTags = Arrays.asList(rackAwareTagsValue.split(",", -1));

Review Comment:
   I think we also need to strip whitespaces here?



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:
##########
@@ -386,6 +386,10 @@ public class GroupCoordinatorConfig {
     public static final String STREAMS_GROUP_MAX_ASSIGNMENT_INTERVAL_MS_DOC = "The maximum interval between assignment updates for a streams group.";
     public static final int STREAMS_GROUP_MAX_ASSIGNMENT_INTERVAL_MS_DEFAULT = 15000;
 
+    public static final String STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG = "group.streams.rack.aware.assignment.tags";
+    public static final String STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DEFAULT = "";
+    public static final String STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DOC = "List of client tag keys used to distribute standby replicas across Kafka Streams instances. When configured, the broker-side assignor will make a best-effort to distribute standby tasks over each client tag dimension.";

Review Comment:
   ```suggestion
       public static final String STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DOC = "List of client tag keys used to distribute standby replicas across Kafka Streams instances. When configured, and the used broker-side assignor supports it, it will make a best-effort to distribute standby tasks over each client tag dimension.";
   ```



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:
##########
@@ -754,6 +766,27 @@ private void checkConstraints() {
             String.format("%s must be greater than or equal to %s", STREAMS_GROUP_TASK_OFFSET_INTERVAL_MS_CONFIG, STREAMS_GROUP_MIN_TASK_OFFSET_INTERVAL_MS_CONFIG));
         require(streamsGroupNumWarmupReplicas <= streamsGroupMaxWarmupReplicas,
             String.format("%s must be less than or equal to %s", STREAMS_GROUP_NUM_WARMUP_REPLICAS_CONFIG, STREAMS_GROUP_MAX_WARMUP_REPLICAS_CONFIG));
+
+        // ConfigDef silently de-duplicates LIST values during parsing, so inspect the raw value to make
+        // sure a broker configured with duplicate rack-aware assignment tags refuses to start.
+        List<String> rawRackAwareAssignmentTags = rawRackAwareAssignmentTags();
+        require(Set.copyOf(rawRackAwareAssignmentTags).size() == rawRackAwareAssignmentTags.size(),
+            String.format("%s must not contain duplicate tag keys.", STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG));
+    }
+
+    /**
+     * Returns the rack-aware assignment tags exactly as configured, before {@link ConfigDef} removes duplicates.
+     */
+    private List<String> rawRackAwareAssignmentTags() {
+        Object rawValue = config.originals().get(STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG);

Review Comment:
   Similar question -- can't we just case this to `String` -- for which case it won't be `String` type?



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:
##########
@@ -467,6 +488,30 @@ public static void validate(
         );
     }
 
+    /**
+     * Rejects an alterConfigs request whose rack-aware assignment tags contain duplicate keys, inspecting the
+     * raw value because {@link ConfigDef} removes duplicates from LIST values before they can be validated.
+     *
+     * @param newGroupConfig The new unparsed group config overrides.
+     */
+    private static void validateNoDuplicateRackAwareAssignmentTags(Map<String, ?> newGroupConfig) {

Review Comment:
   Tracing the code backward, it seems this should be type `Map<String, String>` and thus we can simplify the logic below?
   
   To make it work, we need to also change the type of `validate(...)` above:
   ```
       public static void validate(
           Map<String, String> newGroupConfig,
           ...
   ```



##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfigTest.java:
##########
@@ -603,6 +603,31 @@ private void testStreamsOtherConfigs() {
         configs.put(GroupCoordinatorConfig.STREAMS_GROUP_MAX_WARMUP_REPLICAS_CONFIG, -1);
         assertEquals("Invalid value -1 for configuration group.streams.max.warmup.replicas: Value must be at least 0",
             assertThrows(ConfigException.class, () -> createConfig(configs)).getMessage());
+
+
+        // group.streams.rack.aware.assignment.tags
+
+        // default is empty list
+        configs.clear();
+        GroupCoordinatorConfig defaultTagsConfig = createConfig(configs);
+        assertEquals(List.of(), defaultTagsConfig.streamsGroupRackAwareAssignmentTags());
+
+        // can parse a non-empty value
+        configs.clear();
+        configs.put(GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG, "zone,cluster");
+        GroupCoordinatorConfig nonEmptyTagsConfig = createConfig(configs);
+        assertEquals(List.of("zone", "cluster"), nonEmptyTagsConfig.streamsGroupRackAwareAssignmentTags());
+
+        // rejects empty entries in the list
+        configs.clear();
+        configs.put(GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG, "zone, ");
+        assertThrows(ConfigException.class, () -> createConfig(configs));

Review Comment:
   Should we verify the error message?



##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupConfigTest.java:
##########
@@ -345,6 +350,19 @@ public void testInvalidProps() {
         doTestInvalidProps(props, ConfigException.class);
     }
 
+    @Test
+    public void testStreamsRackAwareAssignmentTagsValidation() {
+        // Duplicate rack-aware assignment tags are rejected rather than silently de-duplicated.
+        Map<String, String> props = createValidGroupConfig();
+        props.put(GroupConfig.STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG, "zone,zone");
+        doTestInvalidProps(props, InvalidConfigurationException.class);
+
+        // Distinct rack-aware assignment tags are accepted.
+        props = createValidGroupConfig();
+        props.put(GroupConfig.STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG, "zone,cluster");
+        doTestValidProps(props);
+    }

Review Comment:
   It might be good to add a few more case for whitespaces? For example `" zone , cluster "` should parse and return two tags `zone` and `cluster` w/o any surrounding whitespaces, right?
   
   Also for the default coordinator config test, not just the group config test here.



##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupMetadataManagerTest.java:
##########
@@ -29405,9 +29669,8 @@ private Map<Uuid, DeleteShareGroupOffsetsResponseData.DeleteShareGroupOffsetsRes
      * This matches what streamsGroupAssignmentConfigs() would return.
      */
     private Map<String, String> getDefaultAssignmentConfigs() {
-        // Use the same default value as GroupCoordinatorConfig.STREAMS_GROUP_NUM_STANDBY_REPLICAS_DEFAULT
-        return new TreeMap<>(Map.of(
-            "num.standby.replicas", String.valueOf(GroupCoordinatorConfig.STREAMS_GROUP_NUM_STANDBY_REPLICAS_DEFAULT)
-        ));
+        Map<String, String> configs = new TreeMap<>();
+        configs.put("num.standby.replicas", String.valueOf(GroupCoordinatorConfig.STREAMS_GROUP_NUM_STANDBY_REPLICAS_DEFAULT));
+        return configs;

Review Comment:
   Seems this change is not necessary?



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on PR #22213:
URL: https://github.com/apache/kafka/pull/22213#issuecomment-5081332388

   Thanks for the PR. Merged to `trunk` to meet feature freeze deadline and unblock other work.
   
   A few thing, I would like to get addresses as follow up PR:
   
   - Use `ConfigDef.parseType(name, value, Type.LIST)` in `GroupCoordinatorConfig.rawRackAwareAssignmentTags()`
     and `GroupConfig.validateNoDuplicateRackAwareAssignmentTags()` instead of hand-rolling `\s*,\s*`.
     Also removes the `(String)` cast on `originals()`.
   - `streamsGroupAssignmentConfigs()` joins the tags into a string, and the MISSING_CLIENT_TAGS check
     splits it back apart in the same heartbeat. Read the `List<String>` directly.
   - `num.standby.replicas` is still written unconditionally, so the "omit default-valued configs"
     fix only covers the new config and the next one added hits the upgrade epoch bump again.
   - Add a test that a v0 `StreamsGroupHeartbeat` never receives status code 6.
   - Constants for `"rack.aware.assignment.tags"` and `"num.standby.replicas"`.
   - Docs: KIP-1071 progress entry in `docs/streams/upgrade-guide.md`.


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3353818484


##########
clients/src/main/resources/common/message/StreamsGroupHeartbeatRequest.json:
##########
@@ -18,7 +18,7 @@
   "type": "request",
   "listeners": ["broker"],
   "name": "StreamsGroupHeartbeatRequest",
-  "validVersions": "0",
+  "validVersions": "0-1",

Review Comment:
   The version was bumped in some other PR in the mean time, so we don't need to do this any longer. That's also why there are merge conflicts. Rebasing to `trunk` will fix this issues.



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########
@@ -541,10 +543,21 @@ private void onSuccessResponse(final StreamsGroupHeartbeatResponse response, fin
         if (statuses != null) {
             streamsRebalanceData.setStatuses(statuses);
             if (!statuses.isEmpty()) {
+                for (StreamsGroupHeartbeatResponseData.Status status : statuses) {

Review Comment:
   Seems we are looping over `statuses` twice now. In this new for-loop and in the below `statuses.streams()...` code.
   
   Might be good to unify the code to only loop onec?



##########
clients/src/main/resources/common/message/StreamsGroupHeartbeatResponse.json:
##########
@@ -17,7 +17,7 @@
   "apiKey": 88,
   "type": "response",
   "name": "StreamsGroupHeartbeatResponse",
-  "validVersions": "0",
+  "validVersions": "0-1",

Review Comment:
   same



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:
##########
@@ -693,7 +699,6 @@ public GroupCoordinatorConfig(AbstractConfig config) {
             String.format("%s must be less than or equal to %s",
                 SHARE_GROUP_ASSIGNMENT_INTERVAL_MS_CONFIG, SHARE_GROUP_MAX_ASSIGNMENT_INTERVAL_MS_CONFIG));
 
-

Review Comment:
   I see -- well, instead of doing this, let's split out a helper method `verifyConfigs()` (or maybe even multiple, one for each "group of configs", like `verifyShareGroupConfigs()`, `verifyStreamsGroupConfigs()` and similar), to make the method really shorter.



##########
clients/src/main/resources/common/message/StreamsGroupHeartbeatResponse.json:
##########
@@ -52,7 +52,6 @@
       "about": "The maximal lag a warm-up task can have to be considered caught-up." },
     { "name": "TaskOffsetIntervalMs", "type": "int32", "versions": "0+",
       "about": "The interval in which the task changelog offsets on a client are updated on the broker. The offsets are sent with the next heartbeat after this time has passed." },
-

Review Comment:
   nit: avoid unnecessary reformatting



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2189,6 +2190,27 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");
+        if (!rackAwareTagsValue.isEmpty()) {
+            List<String> requiredTags = Arrays.stream(rackAwareTagsValue.split(",", -1))
+                .filter(tag -> !tag.isEmpty())
+                .collect(Collectors.toList());
+            Set<String> memberTagKeys = updatedMember.clientTags().keySet();
+            List<String> missingTags = requiredTags.stream()
+                .filter(tag -> !memberTagKeys.contains(tag))
+                .collect(Collectors.toList());
+            if (!missingTags.isEmpty()) {
+                returnedStatus.add(
+                    new Status()
+                        .setStatusCode(StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code())
+                        .setStatusDetail(
+                            String.format("Missing required client tags for rack-aware standby assignment: %s. " +
+                                "Configure them via 'client.tag.<tagKey>' in your Streams config.", missingTags)
+                        )
+                );
+            }
+        }
+

Review Comment:
   Not sure. I am wondering if this is something the assignor needs to decide how to handle?



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -8961,9 +8983,12 @@ private Map<String, String> streamsGroupAssignmentConfigs(String groupId) {
         Optional<GroupConfig> groupConfig = groupConfigManager.groupConfig(groupId);
         final Integer numStandbyReplicas = groupConfig.flatMap(GroupConfig::streamsNumStandbyReplicas)
             .orElse(config.streamsGroupNumStandbyReplicas());
-        return new TreeMap<>(Map.of(
-            "num.standby.replicas", numStandbyReplicas.toString()
-        ));
+        final List<String> rackAwareAssignmentTags = groupConfig.flatMap(GroupConfig::streamsRackAwareAssignmentTags)
+            .orElse(config.streamsGroupRackAwareAssignmentTags());
+        Map<String, String> configs = new TreeMap<>();
+        configs.put("num.standby.replicas", numStandbyReplicas.toString());
+        configs.put("rack.aware.assignment.tags", String.join(",", rackAwareAssignmentTags));
+        return configs;

Review Comment:
   This is a valid point. Guess we have the same problem on https://github.com/apache/kafka/pull/21799
   
   While we could maybe avoid it here (by not adding the config if it's the default, ie, empty string), not sure how to handle the case of PR 21799? And if we cannot fix it over there, it doesn't matter what we do here either.
   
   Even if I am wondering about `acceptable.recovery.lag` now -- it is actually an "assignment configuration" we need to add here? Maybe we need to update PR 21799 to begin with, allowing us to change the code here to only add if non-empty string. \cc @lucasbru 



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3228914309


##########
clients/src/main/resources/common/message/StreamsGroupHeartbeatResponse.json:
##########
@@ -52,6 +52,8 @@
       "about": "The maximal lag a warm-up task can have to be considered caught-up." },
     { "name": "TaskOffsetIntervalMs", "type": "int32", "versions": "0+",
       "about": "The interval in which the task changelog offsets on a client are updated on the broker. The offsets are sent with the next heartbeat after this time has passed." },
+    { "name": "RackAwareAssignmentTags", "type": "[]string", "versions": "0+", "nullableVersions": "0+", "default": "null",
+      "about": "The list of client tag keys used for rack-aware standby task assignment. Null if unchanged since last heartbeat." },

Review Comment:
   Since we changed "sending broker's tags to client and let client do the validation" to "broker do the validation and send a status if some tags are missing", this is not applied anymore.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "lucasbru (via GitHub)" <gi...@apache.org>.
lucasbru commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3418981506


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2206,6 +2207,25 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");

Review Comment:
   Just take into account that these are stored in the StreamsGroupMetadataValue, and parsing then needs to happen on the replay path (when the group metadata loads). So any unhandled parse error will prevent the GC from starting. That's why we chose keeping this a simple string to string copy.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3429456390


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########
@@ -579,10 +581,20 @@ private void onSuccessResponse(final StreamsGroupHeartbeatResponse response, fin
         if (statuses != null) {
             streamsRebalanceData.setStatuses(statuses);
             if (!statuses.isEmpty()) {
-                String statusDetails = statuses.stream()
-                    .map(status -> "(" + status.statusCode() + ") " + status.statusDetail())
-                    .collect(Collectors.joining(", "));
-                logger.warn("Membership is in the following statuses: {}", statusDetails);
+                List<String> statusesToLog = new ArrayList<>();
+                for (StreamsGroupHeartbeatResponseData.Status status : statuses) {
+                    if (status.statusCode() == StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code()) {
+                        if (!status.statusDetail().equals(lastMissingClientTagsDetail)) {
+                            lastMissingClientTagsDetail = status.statusDetail();

Review Comment:
   make sense, changed now



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3321147169


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -8961,9 +8983,12 @@ private Map<String, String> streamsGroupAssignmentConfigs(String groupId) {
         Optional<GroupConfig> groupConfig = groupConfigManager.groupConfig(groupId);
         final Integer numStandbyReplicas = groupConfig.flatMap(GroupConfig::streamsNumStandbyReplicas)
             .orElse(config.streamsGroupNumStandbyReplicas());
-        return new TreeMap<>(Map.of(
-            "num.standby.replicas", numStandbyReplicas.toString()
-        ));
+        final List<String> rackAwareAssignmentTags = groupConfig.flatMap(GroupConfig::streamsRackAwareAssignmentTags)
+            .orElse(config.streamsGroupRackAwareAssignmentTags());
+        Map<String, String> configs = new TreeMap<>();
+        configs.put("num.standby.replicas", numStandbyReplicas.toString());
+        configs.put("rack.aware.assignment.tags", String.join(",", rackAwareAssignmentTags));
+        return configs;

Review Comment:
   I think this change can cause unexpected epoch bump even if there is no `rack.aware.assignment.tags` changes (GroupMetadataManager L2076) during broker rolling upgrade. 
   
   For example, 
   - rolling upgrade before : There is no `rack.aware.assignment.tags`. -> `{"num.standby.replicas":"0"}`
   - rolling upgrade with this PR : `{"num.standby.replicas":"0","rack.aware.assignment.tags":""}`.
   
   So, group epoch is bumped up.
   Given KIP-1071, this is undesirable side effect. 
   
   What do you think?



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2189,6 +2190,27 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");
+        if (!rackAwareTagsValue.isEmpty()) {
+            List<String> requiredTags = Arrays.stream(rackAwareTagsValue.split(",", -1))
+                .filter(tag -> !tag.isEmpty())
+                .collect(Collectors.toList());
+            Set<String> memberTagKeys = updatedMember.clientTags().keySet();
+            List<String> missingTags = requiredTags.stream()
+                .filter(tag -> !memberTagKeys.contains(tag))
+                .collect(Collectors.toList());
+            if (!missingTags.isEmpty()) {
+                returnedStatus.add(
+                    new Status()
+                        .setStatusCode(StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code())
+                        .setStatusDetail(
+                            String.format("Missing required client tags for rack-aware standby assignment: %s. " +
+                                "Configure them via 'client.tag.<tagKey>' in your Streams config.", missingTags)
+                        )
+                );
+            }
+        }
+

Review Comment:
   Should we prevent invalid values from being stored in the member metadata?
   
   Currently, it seems that invalid data can be stored in the member metadata and later passed to the assignor. For example, if a value like zone,,cluster is provided, it appears to be passed to the assignor as-is.
   
   Would it be possible to prevent invalid values from being propagated to other instances through GroupMetadataManager?



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3203903327


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:
##########
@@ -292,6 +298,11 @@ public final class GroupConfig extends AbstractConfig {
             atLeast(0),
             MEDIUM,
             GroupCoordinatorConfig.STREAMS_GROUP_NUM_WARMUP_REPLICAS_DOC)
+        .define(STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG,
+            LIST,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DEFAULT,
+            MEDIUM,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DOC)

Review Comment:
   I believe that `LIST` type does take care of this already? We have an existing test for the "classic" client side config, `StreamsConfigTest#shouldThrowExceptionWhenClientTagRackAwarenessIsConfiguredWithEmptyTag`, and it should work the same broker side?
   
   Might be good to add a test for it (maybe both, coordinator-config, and group-config)?
   
   What also reminds me, that we might want to also have guard on both configs (especially the coordinator one --  for the group one, we can simply reject the config change with an error?) to also ensure that the group-coordinator starts up, even if `group.streams.rack.aware.assignment.tags` is set so something invalid (and maybe fall back to default empty string). -- Would be good to hear from one of @lucasbru @lianetm @AndrewJSchofield @dajac @squah-confluent about it?



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3641007117


##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupConfigTest.java:
##########
@@ -345,6 +350,19 @@ public void testInvalidProps() {
         doTestInvalidProps(props, ConfigException.class);
     }
 
+    @Test
+    public void testStreamsRackAwareAssignmentTagsValidation() {
+        // Duplicate rack-aware assignment tags are rejected rather than silently de-duplicated.
+        Map<String, String> props = createValidGroupConfig();
+        props.put(GroupConfig.STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG, "zone,zone");
+        doTestInvalidProps(props, InvalidConfigurationException.class);
+
+        // Distinct rack-aware assignment tags are accepted.
+        props = createValidGroupConfig();
+        props.put(GroupConfig.STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG, "zone,cluster");
+        doTestValidProps(props);
+    }

Review Comment:
   Done. Added " zone , cluster " cases to both GroupConfigTest and GroupCoordinatorConfigTest, asserting they parse to a clean [zone, cluster], plus a " zone , zone " case verifying  duplicate detection is whitespace insensitive.  



##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupMetadataManagerTest.java:
##########
@@ -29405,9 +29669,8 @@ private Map<Uuid, DeleteShareGroupOffsetsResponseData.DeleteShareGroupOffsetsRes
      * This matches what streamsGroupAssignmentConfigs() would return.
      */
     private Map<String, String> getDefaultAssignmentConfigs() {
-        // Use the same default value as GroupCoordinatorConfig.STREAMS_GROUP_NUM_STANDBY_REPLICAS_DEFAULT
-        return new TreeMap<>(Map.of(
-            "num.standby.replicas", String.valueOf(GroupCoordinatorConfig.STREAMS_GROUP_NUM_STANDBY_REPLICAS_DEFAULT)
-        ));
+        Map<String, String> configs = new TreeMap<>();
+        configs.put("num.standby.replicas", String.valueOf(GroupCoordinatorConfig.STREAMS_GROUP_NUM_STANDBY_REPLICAS_DEFAULT));
+        return configs;

Review Comment:
   reverted



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3455012044


##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupConfigTest.java:
##########
@@ -132,6 +133,7 @@ public void testFromPropsInvalid() {
                 assertPropertyInvalid(name, "not_a_number", "1.0");
             } else if (GroupConfig.ERRORS_DEADLETTERQUEUE_COPY_RECORD_ENABLE_CONFIG.equals(name)) {
                 assertPropertyInvalid(name, "not_a_boolean");
+            } else if (GroupConfig.STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG.equals(name)) {

Review Comment:
   resolved



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3358273433


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -8961,9 +8983,12 @@ private Map<String, String> streamsGroupAssignmentConfigs(String groupId) {
         Optional<GroupConfig> groupConfig = groupConfigManager.groupConfig(groupId);
         final Integer numStandbyReplicas = groupConfig.flatMap(GroupConfig::streamsNumStandbyReplicas)
             .orElse(config.streamsGroupNumStandbyReplicas());
-        return new TreeMap<>(Map.of(
-            "num.standby.replicas", numStandbyReplicas.toString()
-        ));
+        final List<String> rackAwareAssignmentTags = groupConfig.flatMap(GroupConfig::streamsRackAwareAssignmentTags)
+            .orElse(config.streamsGroupRackAwareAssignmentTags());
+        Map<String, String> configs = new TreeMap<>();
+        configs.put("num.standby.replicas", numStandbyReplicas.toString());
+        configs.put("rack.aware.assignment.tags", String.join(",", rackAwareAssignmentTags));
+        return configs;

Review Comment:
   sounds good, I will do the same here
   



##########
clients/src/main/resources/common/message/StreamsGroupHeartbeatRequest.json:
##########
@@ -18,7 +18,7 @@
   "type": "request",
   "listeners": ["broker"],
   "name": "StreamsGroupHeartbeatRequest",
-  "validVersions": "0",
+  "validVersions": "0-1",

Review Comment:
   done



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3382739565


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2189,6 +2190,27 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");
+        if (!rackAwareTagsValue.isEmpty()) {
+            List<String> requiredTags = Arrays.stream(rackAwareTagsValue.split(",", -1))
+                .filter(tag -> !tag.isEmpty())
+                .collect(Collectors.toList());
+            Set<String> memberTagKeys = updatedMember.clientTags().keySet();
+            List<String> missingTags = requiredTags.stream()
+                .filter(tag -> !memberTagKeys.contains(tag))
+                .collect(Collectors.toList());
+            if (!missingTags.isEmpty()) {
+                returnedStatus.add(
+                    new Status()
+                        .setStatusCode(StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code())
+                        .setStatusDetail(
+                            String.format("Missing required client tags for rack-aware standby assignment: %s. " +
+                                "Configure them via 'client.tag.<tagKey>' in your Streams config.", missingTags)
+                        )
+                );
+            }
+        }
+

Review Comment:
   I used the broker side ConfigDef.ValidList which can recongize and handle the empty entry in the list
   



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax merged PR #22213:
URL: https://github.com/apache/kafka/pull/22213


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3640711013


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:
##########
@@ -467,6 +488,30 @@ public static void validate(
         );
     }
 
+    /**
+     * Rejects an alterConfigs request whose rack-aware assignment tags contain duplicate keys, inspecting the
+     * raw value because {@link ConfigDef} removes duplicates from LIST values before they can be validated.
+     *
+     * @param newGroupConfig The new unparsed group config overrides.
+     */
+    private static void validateNoDuplicateRackAwareAssignmentTags(Map<String, ?> newGroupConfig) {

Review Comment:
   sounds good, i'll update it to be all strings. thanks



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3640812777


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:
##########
@@ -386,6 +386,10 @@ public class GroupCoordinatorConfig {
     public static final String STREAMS_GROUP_MAX_ASSIGNMENT_INTERVAL_MS_DOC = "The maximum interval between assignment updates for a streams group.";
     public static final int STREAMS_GROUP_MAX_ASSIGNMENT_INTERVAL_MS_DEFAULT = 15000;
 
+    public static final String STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG = "group.streams.rack.aware.assignment.tags";
+    public static final String STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DEFAULT = "";
+    public static final String STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DOC = "List of client tag keys used to distribute standby replicas across Kafka Streams instances. When configured, the broker-side assignor will make a best-effort to distribute standby tasks over each client tag dimension.";

Review Comment:
   changed! thanks



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "lucasbru (via GitHub)" <gi...@apache.org>.
lucasbru commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3357855758


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -8961,9 +8983,12 @@ private Map<String, String> streamsGroupAssignmentConfigs(String groupId) {
         Optional<GroupConfig> groupConfig = groupConfigManager.groupConfig(groupId);
         final Integer numStandbyReplicas = groupConfig.flatMap(GroupConfig::streamsNumStandbyReplicas)
             .orElse(config.streamsGroupNumStandbyReplicas());
-        return new TreeMap<>(Map.of(
-            "num.standby.replicas", numStandbyReplicas.toString()
-        ));
+        final List<String> rackAwareAssignmentTags = groupConfig.flatMap(GroupConfig::streamsRackAwareAssignmentTags)
+            .orElse(config.streamsGroupRackAwareAssignmentTags());
+        Map<String, String> configs = new TreeMap<>();
+        configs.put("num.standby.replicas", numStandbyReplicas.toString());
+        configs.put("rack.aware.assignment.tags", String.join(",", rackAwareAssignmentTags));
+        return configs;

Review Comment:
   Yeah, I think all new configs need a default value, and we need to remove any configs with default-values from this map.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3382455785


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########
@@ -541,10 +543,21 @@ private void onSuccessResponse(final StreamsGroupHeartbeatResponse response, fin
         if (statuses != null) {
             streamsRebalanceData.setStatuses(statuses);
             if (!statuses.isEmpty()) {
+                for (StreamsGroupHeartbeatResponseData.Status status : statuses) {

Review Comment:
   done



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3190926352


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########


Review Comment:
   adding a client side warning if they are missing some tags broker required



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3203340550


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########
@@ -533,6 +533,18 @@ private void onSuccessResponse(final StreamsGroupHeartbeatResponse response, fin
         streamsRebalanceData.setHeartbeatIntervalMs(data.heartbeatIntervalMs());
         streamsRebalanceData.setTaskOffsetIntervalMs(data.taskOffsetIntervalMs());
 
+        if (data.rackAwareAssignmentTags() != null) {
+            Set<String> clientTagKeys = streamsRebalanceData.clientTags().keySet();
+            for (String requiredTag : data.rackAwareAssignmentTags()) {
+                if (!clientTagKeys.contains(requiredTag)) {
+                    logger.warn("Broker requires client tag '{}' for rack-aware standby assignment, " +
+                        "but this client does not have it configured. " +
+                        "Configure it via 'client.tag.{}' in your Streams config.",
+                        requiredTag, requiredTag);
+                }

Review Comment:
   I think if the broker return a invalid tag, the client will just log a warning like "you should add this tag" but it won't reject the server and since this tag won't be the intersection, it won't change the assignment
   



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3233794627


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########
@@ -533,6 +533,18 @@ private void onSuccessResponse(final StreamsGroupHeartbeatResponse response, fin
         streamsRebalanceData.setHeartbeatIntervalMs(data.heartbeatIntervalMs());
         streamsRebalanceData.setTaskOffsetIntervalMs(data.taskOffsetIntervalMs());
 
+        if (data.rackAwareAssignmentTags() != null) {
+            Set<String> clientTagKeys = streamsRebalanceData.clientTags().keySet();
+            for (String requiredTag : data.rackAwareAssignmentTags()) {
+                if (!clientTagKeys.contains(requiredTag)) {
+                    logger.warn("Broker requires client tag '{}' for rack-aware standby assignment, " +
+                        "but this client does not have it configured. " +
+                        "Configure it via 'client.tag.{}' in your Streams config.",
+                        requiredTag, requiredTag);
+                }

Review Comment:
   Ah, Thanks for your comments! 
   I was also wondering how assignment is expected to behave if the broker receives an invalid rack tag from a client. For example, I could imagine a few possible scenarios:
   
   - A dynamic member joins with an invalid rack tag
   - A static member rejoins with a rack tag that has changed to an invalid value
   
   I suspect this may be handled in a different PR rather than this one, but I was curious about the expected behavior 🤔 



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3417468280


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2206,6 +2207,25 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");

Review Comment:
   @lucasbru -- Wondering why `currentAssignmentConfigs` is `Map<String, String>`? Would be convenient here, if the values would be properly typed here, so we don't have to parse the tag-list here? Atm, we would parse it on every heartbeat..



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3640736251


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2354,6 +2357,27 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");
+        // The MISSING_CLIENT_TAGS status (code 6) requires version 1 of the RPC: version 0 clients
+        // throw on unknown status codes, so it must not be sent to them.
+        if (requestApiVersion >= 1 && !rackAwareTagsValue.isEmpty()) {
+            List<String> requiredTags = Arrays.asList(rackAwareTagsValue.split(",", -1));

Review Comment:
   ok sounds good, i just wondering if there any other types we need to validate, I remember we said the assignor should be responsible whether their tag names are correct or not?



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3203826150


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:
##########
@@ -553,6 +557,7 @@ public class GroupCoordinatorConfig {
     private final int streamsGroupMaxSize;
     private final int streamsGroupNumStandbyReplicas;
     private final int streamsGroupMaxStandbyReplicas;
+    private final List<String> streamsGroupRackAwareAssignmentTags;

Review Comment:
   Doesn't really matter, but why do insert this here, and not at the end of he list?



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2140,11 +2141,16 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
         }
 
         // Prepare the response.
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");
+        List<String> rackAwareAssignmentTags = rackAwareTagsValue.isEmpty()
+            ? Collections.emptyList()
+            : Arrays.asList(rackAwareTagsValue.split(",", -1));
         StreamsGroupHeartbeatResponseData response = new StreamsGroupHeartbeatResponseData()
             .setMemberId(updatedMember.memberId())
             .setMemberEpoch(updatedMember.memberEpoch())
             .setHeartbeatIntervalMs(streamsGroupHeartbeatIntervalMs(groupId))
-            .setTaskOffsetIntervalMs(streamsGroupTaskOffsetIntervalMs(groupId));
+            .setTaskOffsetIntervalMs(streamsGroupTaskOffsetIntervalMs(groupId))
+            .setRackAwareAssignmentTags(rackAwareAssignmentTags);

Review Comment:
   Yes.



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########
@@ -533,6 +533,18 @@ private void onSuccessResponse(final StreamsGroupHeartbeatResponse response, fin
         streamsRebalanceData.setHeartbeatIntervalMs(data.heartbeatIntervalMs());
         streamsRebalanceData.setTaskOffsetIntervalMs(data.taskOffsetIntervalMs());
 
+        if (data.rackAwareAssignmentTags() != null) {
+            Set<String> clientTagKeys = streamsRebalanceData.clientTags().keySet();
+            for (String requiredTag : data.rackAwareAssignmentTags()) {
+                if (!clientTagKeys.contains(requiredTag)) {
+                    logger.warn("Broker requires client tag '{}' for rack-aware standby assignment, " +
+                        "but this client does not have it configured. " +
+                        "Configure it via 'client.tag.{}' in your Streams config.",
+                        requiredTag, requiredTag);
+                }

Review Comment:
   Not sure what you mean by "reject it" @chickenchickenlove ?
   
   `rack.aware.assignment.tags` are the tags configure for the assignor to use, to compute the assignment. The client is not using them by itself, so there is nothing to be rejected.
   
   The logging we do here is to inform the developer/operator of the client, that the broker uses some tags for rack aware assignment, but the client doesn't set these tags, to rack aware assignment might not work as expected.



##########
clients/src/main/resources/common/message/StreamsGroupHeartbeatResponse.json:
##########


Review Comment:
   This will be fixed via https://github.com/apache/kafka/pull/21799



##########
clients/src/main/resources/common/message/StreamsGroupHeartbeatResponse.json:
##########
@@ -52,6 +52,8 @@
       "about": "The maximal lag a warm-up task can have to be considered caught-up." },
     { "name": "TaskOffsetIntervalMs", "type": "int32", "versions": "0+",
       "about": "The interval in which the task changelog offsets on a client are updated on the broker. The offsets are sent with the next heartbeat after this time has passed." },
+    { "name": "RackAwareAssignmentTags", "type": "[]string", "versions": "0+", "nullableVersions": "0+", "default": "null",
+      "about": "The list of client tag keys used for rack-aware standby task assignment. Null if unchanged since last heartbeat." },

Review Comment:
   Yes, this need to get changed to `"versions": "1+"`, and `"nullableVersions": "1+"`
   
   But this PR depends on https://github.com/apache/kafka/pull/21799 -- do I guess it's ok for now and we can fix after the other PR got merged



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:
##########
@@ -292,6 +298,11 @@ public final class GroupConfig extends AbstractConfig {
             atLeast(0),
             MEDIUM,
             GroupCoordinatorConfig.STREAMS_GROUP_NUM_WARMUP_REPLICAS_DOC)
+        .define(STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG,
+            LIST,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DEFAULT,
+            MEDIUM,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DOC)

Review Comment:
   I believe that `LIST` type does take care of this already? We have an existing test for the "classic" client side config, `StreamsConfigTest#shouldThrowExceptionWhenClientTagRackAwarenessIsConfiguredWithEmptyTag`, and it should work the same broker side?
   
   Might be good to add a test for it (maybe both, coordinator-config, and group-config)?
   
   What also reminds me, that we might want to also have guard on both configs (especially the coordinator one --  for the group one, we can simply reject the config change with an error?) to also ensure that the group-coordinator starts up, even if `group.streams.rack.aware.assignment.tags` is set so something invalid (and maybe fall back to default empty "string"). -- Would be good to hear from one of @lucasbru @lianetm @AndrewJSchofield @dajac @squah-confluent about it?



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:
##########
@@ -693,7 +699,6 @@ public GroupCoordinatorConfig(AbstractConfig config) {
             String.format("%s must be less than or equal to %s",
                 SHARE_GROUP_ASSIGNMENT_INTERVAL_MS_CONFIG, SHARE_GROUP_MAX_ASSIGNMENT_INTERVAL_MS_CONFIG));
 
-

Review Comment:
   nit: keep double empty line to separate "share" from "streams" section clearly.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3228920693


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:
##########
@@ -292,6 +298,11 @@ public final class GroupConfig extends AbstractConfig {
             atLeast(0),
             MEDIUM,
             GroupCoordinatorConfig.STREAMS_GROUP_NUM_WARMUP_REPLICAS_DOC)
+        .define(STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG,
+            LIST,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DEFAULT,
+            MEDIUM,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DOC)

Review Comment:
   I have handled it with a filter, and add the test of "zone,,cluter" tags config



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:
##########
@@ -292,6 +298,11 @@ public final class GroupConfig extends AbstractConfig {
             atLeast(0),
             MEDIUM,
             GroupCoordinatorConfig.STREAMS_GROUP_NUM_WARMUP_REPLICAS_DOC)
+        .define(STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG,
+            LIST,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DEFAULT,
+            MEDIUM,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DOC)

Review Comment:
   I have handled it with a filter, and add the test of "zone,,cluster" tags config



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3228956984


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:
##########
@@ -693,7 +699,6 @@ public GroupCoordinatorConfig(AbstractConfig config) {
             String.format("%s must be less than or equal to %s",
                 SHARE_GROUP_ASSIGNMENT_INTERVAL_MS_CONFIG, SHARE_GROUP_MAX_ASSIGNMENT_INTERVAL_MS_CONFIG));
 
-

Review Comment:
   This one its the constructor exceed 170 lines, if I don't delete a newline I can't pass the check of ./gradlew clean build -x test



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3327765553


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2189,6 +2190,27 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");
+        if (!rackAwareTagsValue.isEmpty()) {
+            List<String> requiredTags = Arrays.stream(rackAwareTagsValue.split(",", -1))
+                .filter(tag -> !tag.isEmpty())
+                .collect(Collectors.toList());
+            Set<String> memberTagKeys = updatedMember.clientTags().keySet();
+            List<String> missingTags = requiredTags.stream()
+                .filter(tag -> !memberTagKeys.contains(tag))
+                .collect(Collectors.toList());
+            if (!missingTags.isEmpty()) {
+                returnedStatus.add(
+                    new Status()
+                        .setStatusCode(StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code())
+                        .setStatusDetail(
+                            String.format("Missing required client tags for rack-aware standby assignment: %s. " +
+                                "Configure them via 'client.tag.<tagKey>' in your Streams config.", missingTags)
+                        )
+                );
+            }
+        }
+

Review Comment:
   I think this make sense, but I am not sure if the type of rack is limited, I can investigate this.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3641345662


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManagerTest.java:
##########
@@ -1700,6 +1701,94 @@ private ClientResponse buildClientErrorResponse(final Errors error, final String
         );
     }
 
+    @Test
+    public void testMissingClientTagsStatusLogsWarningOnlyOnce() {
+        try (
+            final MockedConstruction<HeartbeatRequestState> ignored = mockConstruction(
+                HeartbeatRequestState.class,
+                (mock, context) -> when(mock.canSendRequest(time.milliseconds())).thenReturn(true));
+            final LogCaptureAppender logAppender = LogCaptureAppender.createAndRegister(StreamsGroupHeartbeatRequestManager.class)
+        ) {
+            logAppender.setClassLogger(StreamsGroupHeartbeatRequestManager.class, Level.WARN);
+            final StreamsGroupHeartbeatRequestManager heartbeatRequestManager = createStreamsGroupHeartbeatRequestManager();
+            when(coordinatorRequestManager.coordinator()).thenReturn(Optional.of(coordinatorNode));
+            when(membershipManager.groupId()).thenReturn(GROUP_ID);
+            when(membershipManager.memberId()).thenReturn(MEMBER_ID);
+            when(membershipManager.memberEpoch()).thenReturn(MEMBER_EPOCH);
+            when(membershipManager.groupInstanceId()).thenReturn(Optional.of(INSTANCE_ID));
+
+            final String statusDetail = "Missing required client tags for rack-aware standby assignment: [zone, cluster]";
+
+            // First heartbeat with MISSING_CLIENT_TAGS status
+            final NetworkClientDelegate.PollResult result1 = heartbeatRequestManager.poll(time.milliseconds());
+            assertEquals(1, result1.unsentRequests.size());
+
+            final ClientResponse response1 = new ClientResponse(
+                new RequestHeader(ApiKeys.STREAMS_GROUP_HEARTBEAT, (short) 1, "", 1),
+                null, "-1", time.milliseconds(), time.milliseconds(), false, null, null,
+                new StreamsGroupHeartbeatResponse(
+                    new StreamsGroupHeartbeatResponseData()
+                        .setHeartbeatIntervalMs((int) RECEIVED_HEARTBEAT_INTERVAL_MS)
+                        .setStatus(List.of(new StreamsGroupHeartbeatResponseData.Status()
+                            .setStatusCode(StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code())
+                            .setStatusDetail(statusDetail)))
+                )
+            );
+            result1.unsentRequests.get(0).handler().onComplete(response1);
+
+            long firstWarnCount = logAppender.getMessages("WARN").stream()
+                .filter(m -> m.contains("Missing required client tags"))

Review Comment:
   added, thanks



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3640679264


##########
docs/getting-started/upgrade.md:
##########
@@ -99,6 +99,7 @@ Note: Apache Kafka 4.2 only supports KRaft mode - ZooKeeper mode has been remove
 
 ### Notable changes in 4.2.0
 
+

Review Comment:
   it's a typo, sorry about that



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3203711122


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########
@@ -533,6 +533,18 @@ private void onSuccessResponse(final StreamsGroupHeartbeatResponse response, fin
         streamsRebalanceData.setHeartbeatIntervalMs(data.heartbeatIntervalMs());
         streamsRebalanceData.setTaskOffsetIntervalMs(data.taskOffsetIntervalMs());
 
+        if (data.rackAwareAssignmentTags() != null) {
+            Set<String> clientTagKeys = streamsRebalanceData.clientTags().keySet();
+            for (String requiredTag : data.rackAwareAssignmentTags()) {
+                if (!clientTagKeys.contains(requiredTag)) {
+                    logger.warn("Broker requires client tag '{}' for rack-aware standby assignment, " +
+                        "but this client does not have it configured. " +
+                        "Configure it via 'client.tag.{}' in your Streams config.",
+                        requiredTag, requiredTag);
+                }

Review Comment:
   Not sure what you mean by "reject it" @chickenchickenlove ?
   
   `rack.aware.assignment.tags` are the tags configure for the assignor to use, to compute the assignment. The client is not using them by itself, so there is nothing to be rejected.
   
   The logging we do here is to inform the developer/operator of the client, that the broker uses some tags for rack aware assignment, but the client doesn't set these tags, so rack aware assignment might not work as expected.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3574711440


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########
@@ -533,6 +533,18 @@ private void onSuccessResponse(final StreamsGroupHeartbeatResponse response, fin
         streamsRebalanceData.setHeartbeatIntervalMs(data.heartbeatIntervalMs());
         streamsRebalanceData.setTaskOffsetIntervalMs(data.taskOffsetIntervalMs());
 
+        if (data.rackAwareAssignmentTags() != null) {
+            Set<String> clientTagKeys = streamsRebalanceData.clientTags().keySet();
+            for (String requiredTag : data.rackAwareAssignmentTags()) {
+                if (!clientTagKeys.contains(requiredTag)) {
+                    logger.warn("Broker requires client tag '{}' for rack-aware standby assignment, " +
+                        "but this client does not have it configured. " +
+                        "Configure it via 'client.tag.{}' in your Streams config.",
+                        requiredTag, requiredTag);
+                }

Review Comment:
   Yes, we need to figure this out when we work on the rack-aware assignment logic itself. This PR does only do the wiring to get all the metadata into the right place (client side, as well as broker side, ie, into the assignor).
   
   But the current broker side "sticky" assignor would ignore these information atm, and we need follow up work to close this gap.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3382739565


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2189,6 +2190,27 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");
+        if (!rackAwareTagsValue.isEmpty()) {
+            List<String> requiredTags = Arrays.stream(rackAwareTagsValue.split(",", -1))
+                .filter(tag -> !tag.isEmpty())
+                .collect(Collectors.toList());
+            Set<String> memberTagKeys = updatedMember.clientTags().keySet();
+            List<String> missingTags = requiredTags.stream()
+                .filter(tag -> !memberTagKeys.contains(tag))
+                .collect(Collectors.toList());
+            if (!missingTags.isEmpty()) {
+                returnedStatus.add(
+                    new Status()
+                        .setStatusCode(StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code())
+                        .setStatusDetail(
+                            String.format("Missing required client tags for rack-aware standby assignment: %s. " +
+                                "Configure them via 'client.tag.<tagKey>' in your Streams config.", missingTags)
+                        )
+                );
+            }
+        }
+

Review Comment:
   I used the broker side ConfigDef.ValidList which can recongize and handle the empty entry in the list
   



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3190926352


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########


Review Comment:
   adding a client side warning if they are missing some tags broker required



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "chickenchickenlove (via GitHub)" <gi...@apache.org>.
chickenchickenlove commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3201549377


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2140,11 +2141,16 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
         }
 
         // Prepare the response.
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");
+        List<String> rackAwareAssignmentTags = rackAwareTagsValue.isEmpty()
+            ? Collections.emptyList()
+            : Arrays.asList(rackAwareTagsValue.split(",", -1));
         StreamsGroupHeartbeatResponseData response = new StreamsGroupHeartbeatResponseData()
             .setMemberId(updatedMember.memberId())
             .setMemberEpoch(updatedMember.memberEpoch())
             .setHeartbeatIntervalMs(streamsGroupHeartbeatIntervalMs(groupId))
-            .setTaskOffsetIntervalMs(streamsGroupTaskOffsetIntervalMs(groupId));
+            .setTaskOffsetIntervalMs(streamsGroupTaskOffsetIntervalMs(groupId))
+            .setRackAwareAssignmentTags(rackAwareAssignmentTags);

Review Comment:
   > The list of client tag keys used for rack-aware standby task assignment. Null if unchanged since last heartbeat.
   
   Regarding statement in the `StreamsGroupHeartbeatResponse.json`, 
   If there is no change, should we set `null`?



##########
clients/src/main/resources/common/message/StreamsGroupHeartbeatResponse.json:
##########


Review Comment:
   Old v0 clients don't know about `RackAwareAssignmentTags`. 
   So, IMHO, old v0 clients fail to decode `StreamsGroupHeartbeatResponse`.
   Should we set `validVersions` to `0-1`?



##########
clients/src/main/resources/common/message/StreamsGroupHeartbeatResponse.json:
##########
@@ -52,6 +52,8 @@
       "about": "The maximal lag a warm-up task can have to be considered caught-up." },
     { "name": "TaskOffsetIntervalMs", "type": "int32", "versions": "0+",
       "about": "The interval in which the task changelog offsets on a client are updated on the broker. The offsets are sent with the next heartbeat after this time has passed." },
+    { "name": "RackAwareAssignmentTags", "type": "[]string", "versions": "0+", "nullableVersions": "0+", "default": "null",
+      "about": "The list of client tag keys used for rack-aware standby task assignment. Null if unchanged since last heartbeat." },

Review Comment:
   Regarding [KIP-1071](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1071%3A+Streams+Rebalance+Protocol), 
   1. Should we set `versions` to `1+`? 
   2. Should we use `The assignment tags used by the group coordinator for rack aware standby task assignment.` for the `about` section?



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupConfig.java:
##########
@@ -292,6 +298,11 @@ public final class GroupConfig extends AbstractConfig {
             atLeast(0),
             MEDIUM,
             GroupCoordinatorConfig.STREAMS_GROUP_NUM_WARMUP_REPLICAS_DOC)
+        .define(STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG,
+            LIST,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DEFAULT,
+            MEDIUM,
+            GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_DOC)

Review Comment:
   Would it make sense to add a Validator here?
   If config is misconfigured as `group.streams.rack.aware.assignment.tags=zone,,cluster`, it might be parsed to `List.of("zone", "", "cluster)`.



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########
@@ -533,6 +533,18 @@ private void onSuccessResponse(final StreamsGroupHeartbeatResponse response, fin
         streamsRebalanceData.setHeartbeatIntervalMs(data.heartbeatIntervalMs());
         streamsRebalanceData.setTaskOffsetIntervalMs(data.taskOffsetIntervalMs());
 
+        if (data.rackAwareAssignmentTags() != null) {
+            Set<String> clientTagKeys = streamsRebalanceData.clientTags().keySet();
+            for (String requiredTag : data.rackAwareAssignmentTags()) {
+                if (!clientTagKeys.contains(requiredTag)) {
+                    logger.warn("Broker requires client tag '{}' for rack-aware standby assignment, " +
+                        "but this client does not have it configured. " +
+                        "Configure it via 'client.tag.{}' in your Streams config.",
+                        requiredTag, requiredTag);
+                }

Review Comment:
   Just out of curiosity, if the server returns an invalid tag, will the client-side validation added in another PR reject it?



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3357740554


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -8961,9 +8983,12 @@ private Map<String, String> streamsGroupAssignmentConfigs(String groupId) {
         Optional<GroupConfig> groupConfig = groupConfigManager.groupConfig(groupId);
         final Integer numStandbyReplicas = groupConfig.flatMap(GroupConfig::streamsNumStandbyReplicas)
             .orElse(config.streamsGroupNumStandbyReplicas());
-        return new TreeMap<>(Map.of(
-            "num.standby.replicas", numStandbyReplicas.toString()
-        ));
+        final List<String> rackAwareAssignmentTags = groupConfig.flatMap(GroupConfig::streamsRackAwareAssignmentTags)
+            .orElse(config.streamsGroupRackAwareAssignmentTags());
+        Map<String, String> configs = new TreeMap<>();
+        configs.put("num.standby.replicas", numStandbyReplicas.toString());
+        configs.put("rack.aware.assignment.tags", String.join(",", rackAwareAssignmentTags));
+        return configs;

Review Comment:
   Ok. I removed the config on the other PR. -- So I think we could do a empty-string check here to avoid the unnecessary epoch bump during an upgrade?
   
   But if we ever add new configs in the future, we might hit the same issue again, so also wondering if we would need to accept this issue in general, or if there might be a more general fix?



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KSTREAMS-8781: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3417141917


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManager.java:
##########
@@ -579,10 +581,20 @@ private void onSuccessResponse(final StreamsGroupHeartbeatResponse response, fin
         if (statuses != null) {
             streamsRebalanceData.setStatuses(statuses);
             if (!statuses.isEmpty()) {
-                String statusDetails = statuses.stream()
-                    .map(status -> "(" + status.statusCode() + ") " + status.statusDetail())
-                    .collect(Collectors.joining(", "));
-                logger.warn("Membership is in the following statuses: {}", statusDetails);
+                List<String> statusesToLog = new ArrayList<>();
+                for (StreamsGroupHeartbeatResponseData.Status status : statuses) {
+                    if (status.statusCode() == StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code()) {
+                        if (!status.statusDetail().equals(lastMissingClientTagsDetail)) {
+                            lastMissingClientTagsDetail = status.statusDetail();

Review Comment:
   I think we also need to reset `lastMissingClientTagsDetail = null`, if no reported `status == MISSING_CLIENT_TAGS` ?
   
   Assume the client has configure tag `foo`. The broker also has configured `foo`. All good. Next, broker side config change to require `foo,bar`. Client log an error ones. -- Next, broker is reverted to only require `foo`, so we should clear the flag, as we are not in any error state any longer



##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManagerTest.java:
##########
@@ -1700,6 +1701,94 @@ private ClientResponse buildClientErrorResponse(final Errors error, final String
         );
     }
 
+    @Test
+    public void testMissingClientTagsStatusLogsWarningOnlyOnce() {
+        try (
+            final MockedConstruction<HeartbeatRequestState> ignored = mockConstruction(
+                HeartbeatRequestState.class,
+                (mock, context) -> when(mock.canSendRequest(time.milliseconds())).thenReturn(true));
+            final LogCaptureAppender logAppender = LogCaptureAppender.createAndRegister(StreamsGroupHeartbeatRequestManager.class)
+        ) {
+            logAppender.setClassLogger(StreamsGroupHeartbeatRequestManager.class, Level.WARN);
+            final StreamsGroupHeartbeatRequestManager heartbeatRequestManager = createStreamsGroupHeartbeatRequestManager();
+            when(coordinatorRequestManager.coordinator()).thenReturn(Optional.of(coordinatorNode));
+            when(membershipManager.groupId()).thenReturn(GROUP_ID);
+            when(membershipManager.memberId()).thenReturn(MEMBER_ID);
+            when(membershipManager.memberEpoch()).thenReturn(MEMBER_EPOCH);
+            when(membershipManager.groupInstanceId()).thenReturn(Optional.of(INSTANCE_ID));
+
+            final String statusDetail = "Missing required client tags for rack-aware standby assignment: [zone, cluster]";
+
+            // First heartbeat with MISSING_CLIENT_TAGS status
+            final NetworkClientDelegate.PollResult result1 = heartbeatRequestManager.poll(time.milliseconds());
+            assertEquals(1, result1.unsentRequests.size());
+
+            final ClientResponse response1 = new ClientResponse(
+                new RequestHeader(ApiKeys.STREAMS_GROUP_HEARTBEAT, (short) 1, "", 1),
+                null, "-1", time.milliseconds(), time.milliseconds(), false, null, null,
+                new StreamsGroupHeartbeatResponse(
+                    new StreamsGroupHeartbeatResponseData()
+                        .setHeartbeatIntervalMs((int) RECEIVED_HEARTBEAT_INTERVAL_MS)
+                        .setStatus(List.of(new StreamsGroupHeartbeatResponseData.Status()
+                            .setStatusCode(StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code())
+                            .setStatusDetail(statusDetail)))
+                )
+            );
+            result1.unsentRequests.get(0).handler().onComplete(response1);
+
+            long firstWarnCount = logAppender.getMessages("WARN").stream()
+                .filter(m -> m.contains("Missing required client tags"))
+                .count();
+            assertEquals(1, firstWarnCount);
+
+            // Second heartbeat with the same status — should NOT log again
+            final NetworkClientDelegate.PollResult result2 = heartbeatRequestManager.poll(time.milliseconds());
+            assertEquals(1, result2.unsentRequests.size());
+
+            final ClientResponse response2 = new ClientResponse(
+                new RequestHeader(ApiKeys.STREAMS_GROUP_HEARTBEAT, (short) 1, "", 1),
+                null, "-1", time.milliseconds(), time.milliseconds(), false, null, null,
+                new StreamsGroupHeartbeatResponse(
+                    new StreamsGroupHeartbeatResponseData()
+                        .setHeartbeatIntervalMs((int) RECEIVED_HEARTBEAT_INTERVAL_MS)
+                        .setStatus(List.of(new StreamsGroupHeartbeatResponseData.Status()
+                            .setStatusCode(StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code())
+                            .setStatusDetail(statusDetail)))
+                )
+            );
+            result2.unsentRequests.get(0).handler().onComplete(response2);
+
+            long secondWarnCount = logAppender.getMessages("WARN").stream()
+                .filter(m -> m.contains("Missing required client tags"))
+                .count();
+            assertEquals(1, secondWarnCount, "MISSING_CLIENT_TAGS warning should not be logged again for the same detail");
+
+            // Third heartbeat with a DIFFERENT status detail — should log again
+            final String changedStatusDetail = "Missing required client tags for rack-aware standby assignment: [zone]";
+
+            final NetworkClientDelegate.PollResult result3 = heartbeatRequestManager.poll(time.milliseconds());
+            assertEquals(1, result3.unsentRequests.size());
+
+            final ClientResponse response3 = new ClientResponse(
+                new RequestHeader(ApiKeys.STREAMS_GROUP_HEARTBEAT, (short) 1, "", 1),
+                null, "-1", time.milliseconds(), time.milliseconds(), false, null, null,
+                new StreamsGroupHeartbeatResponse(
+                    new StreamsGroupHeartbeatResponseData()
+                        .setHeartbeatIntervalMs((int) RECEIVED_HEARTBEAT_INTERVAL_MS)
+                        .setStatus(List.of(new StreamsGroupHeartbeatResponseData.Status()
+                            .setStatusCode(StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code())
+                            .setStatusDetail(changedStatusDetail)))
+                )
+            );
+            result3.unsentRequests.get(0).handler().onComplete(response3);
+
+            long thirdWarnCount = logAppender.getMessages("WARN").stream()
+                .filter(m -> m.contains("Missing required client tags"))
+                .count();
+            assertEquals(2, thirdWarnCount, "MISSING_CLIENT_TAGS warning should be logged again when the detail changes");

Review Comment:
   Also check that only `[zone]` is logged now in the second log line (might require a second `assertEquals` 



##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupConfigTest.java:
##########
@@ -132,6 +133,7 @@ public void testFromPropsInvalid() {
                 assertPropertyInvalid(name, "not_a_number", "1.0");
             } else if (GroupConfig.ERRORS_DEADLETTERQUEUE_COPY_RECORD_ENABLE_CONFIG.equals(name)) {
                 assertPropertyInvalid(name, "not_a_boolean");
+            } else if (GroupConfig.STREAMS_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG.equals(name)) {

Review Comment:
   Why is the block empty?



##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/StreamsGroupHeartbeatRequestManagerTest.java:
##########
@@ -1700,6 +1701,94 @@ private ClientResponse buildClientErrorResponse(final Errors error, final String
         );
     }
 
+    @Test
+    public void testMissingClientTagsStatusLogsWarningOnlyOnce() {
+        try (
+            final MockedConstruction<HeartbeatRequestState> ignored = mockConstruction(
+                HeartbeatRequestState.class,
+                (mock, context) -> when(mock.canSendRequest(time.milliseconds())).thenReturn(true));
+            final LogCaptureAppender logAppender = LogCaptureAppender.createAndRegister(StreamsGroupHeartbeatRequestManager.class)
+        ) {
+            logAppender.setClassLogger(StreamsGroupHeartbeatRequestManager.class, Level.WARN);
+            final StreamsGroupHeartbeatRequestManager heartbeatRequestManager = createStreamsGroupHeartbeatRequestManager();
+            when(coordinatorRequestManager.coordinator()).thenReturn(Optional.of(coordinatorNode));
+            when(membershipManager.groupId()).thenReturn(GROUP_ID);
+            when(membershipManager.memberId()).thenReturn(MEMBER_ID);
+            when(membershipManager.memberEpoch()).thenReturn(MEMBER_EPOCH);
+            when(membershipManager.groupInstanceId()).thenReturn(Optional.of(INSTANCE_ID));
+
+            final String statusDetail = "Missing required client tags for rack-aware standby assignment: [zone, cluster]";
+
+            // First heartbeat with MISSING_CLIENT_TAGS status
+            final NetworkClientDelegate.PollResult result1 = heartbeatRequestManager.poll(time.milliseconds());
+            assertEquals(1, result1.unsentRequests.size());
+
+            final ClientResponse response1 = new ClientResponse(
+                new RequestHeader(ApiKeys.STREAMS_GROUP_HEARTBEAT, (short) 1, "", 1),
+                null, "-1", time.milliseconds(), time.milliseconds(), false, null, null,
+                new StreamsGroupHeartbeatResponse(
+                    new StreamsGroupHeartbeatResponseData()
+                        .setHeartbeatIntervalMs((int) RECEIVED_HEARTBEAT_INTERVAL_MS)
+                        .setStatus(List.of(new StreamsGroupHeartbeatResponseData.Status()
+                            .setStatusCode(StreamsGroupHeartbeatResponse.Status.MISSING_CLIENT_TAGS.code())
+                            .setStatusDetail(statusDetail)))
+                )
+            );
+            result1.unsentRequests.get(0).handler().onComplete(response1);
+
+            long firstWarnCount = logAppender.getMessages("WARN").stream()
+                .filter(m -> m.contains("Missing required client tags"))

Review Comment:
   Should we also check if `[zone, cluster]` is correctly contained ?



##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -2206,6 +2207,25 @@ private CoordinatorResult<StreamsGroupHeartbeatResult, CoordinatorRecord> stream
                 )
         ));
 
+        String rackAwareTagsValue = currentAssignmentConfigs.getOrDefault("rack.aware.assignment.tags", "");

Review Comment:
   @lucasbru -- Wondering why `currentAssignmentConfigs` is `Map<String, String>`? Would be convenient here, if the values would be properly types here, so we don't have to parse the tag-list here? Atm, we would parse it on every heartbeat..



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3641014978


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfig.java:
##########
@@ -754,6 +766,27 @@ private void checkConstraints() {
             String.format("%s must be greater than or equal to %s", STREAMS_GROUP_TASK_OFFSET_INTERVAL_MS_CONFIG, STREAMS_GROUP_MIN_TASK_OFFSET_INTERVAL_MS_CONFIG));
         require(streamsGroupNumWarmupReplicas <= streamsGroupMaxWarmupReplicas,
             String.format("%s must be less than or equal to %s", STREAMS_GROUP_NUM_WARMUP_REPLICAS_CONFIG, STREAMS_GROUP_MAX_WARMUP_REPLICAS_CONFIG));
+
+        // ConfigDef silently de-duplicates LIST values during parsing, so inspect the raw value to make
+        // sure a broker configured with duplicate rack-aware assignment tags refuses to start.
+        List<String> rawRackAwareAssignmentTags = rawRackAwareAssignmentTags();
+        require(Set.copyOf(rawRackAwareAssignmentTags).size() == rawRackAwareAssignmentTags.size(),
+            String.format("%s must not contain duplicate tag keys.", STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG));
+    }
+
+    /**
+     * Returns the rack-aware assignment tags exactly as configured, before {@link ConfigDef} removes duplicates.
+     */
+    private List<String> rawRackAwareAssignmentTags() {
+        Object rawValue = config.originals().get(STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG);

Review Comment:
   I have changed this, was considering List maybe but think it's a dead branch. thanks



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3641011226


##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupCoordinatorConfigTest.java:
##########
@@ -603,6 +603,31 @@ private void testStreamsOtherConfigs() {
         configs.put(GroupCoordinatorConfig.STREAMS_GROUP_MAX_WARMUP_REPLICAS_CONFIG, -1);
         assertEquals("Invalid value -1 for configuration group.streams.max.warmup.replicas: Value must be at least 0",
             assertThrows(ConfigException.class, () -> createConfig(configs)).getMessage());
+
+
+        // group.streams.rack.aware.assignment.tags
+
+        // default is empty list
+        configs.clear();
+        GroupCoordinatorConfig defaultTagsConfig = createConfig(configs);
+        assertEquals(List.of(), defaultTagsConfig.streamsGroupRackAwareAssignmentTags());
+
+        // can parse a non-empty value
+        configs.clear();
+        configs.put(GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG, "zone,cluster");
+        GroupCoordinatorConfig nonEmptyTagsConfig = createConfig(configs);
+        assertEquals(List.of("zone", "cluster"), nonEmptyTagsConfig.streamsGroupRackAwareAssignmentTags());
+
+        // rejects empty entries in the list
+        configs.clear();
+        configs.put(GroupCoordinatorConfig.STREAMS_GROUP_RACK_AWARE_ASSIGNMENT_TAGS_CONFIG, "zone, ");
+        assertThrows(ConfigException.class, () -> createConfig(configs));

Review Comment:
   Done, have updated all the test to verify error messages are also match



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "gabriellefu (via GitHub)" <gi...@apache.org>.
gabriellefu commented on code in PR #22213:
URL: https://github.com/apache/kafka/pull/22213#discussion_r3641008513


##########
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupMetadataManagerTest.java:
##########
@@ -29405,9 +29669,8 @@ private Map<Uuid, DeleteShareGroupOffsetsResponseData.DeleteShareGroupOffsetsRes
      * This matches what streamsGroupAssignmentConfigs() would return.
      */
     private Map<String, String> getDefaultAssignmentConfigs() {
-        // Use the same default value as GroupCoordinatorConfig.STREAMS_GROUP_NUM_STANDBY_REPLICAS_DEFAULT
-        return new TreeMap<>(Map.of(
-            "num.standby.replicas", String.valueOf(GroupCoordinatorConfig.STREAMS_GROUP_NUM_STANDBY_REPLICAS_DEFAULT)
-        ));
+        Map<String, String> configs = new TreeMap<>();
+        configs.put("num.standby.replicas", String.valueOf(GroupCoordinatorConfig.STREAMS_GROUP_NUM_STANDBY_REPLICAS_DEFAULT));
+        return configs;

Review Comment:
   reverted



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] KAFKA-20744: Add back `rack.aware.assignment.tags` config [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #22213:
URL: https://github.com/apache/kafka/pull/22213#issuecomment-6166043294

   > Docs: KIP-1071 progress entry in docs/streams/upgrade-guide.md.
   
   @gabriellefu Do you have free time to address this? 4.4.0 is being released and we are updating the site, so it would be good to have this change in the 4.4.0 docs :)


-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org