KAFKA-20246: Add clusterId and nodeId to ApiVersionsRequest (2/N)#22187
Open
AndrewJSchofield wants to merge 1 commit intoapache:trunkfrom
Open
KAFKA-20246: Add clusterId and nodeId to ApiVersionsRequest (2/N)#22187AndrewJSchofield wants to merge 1 commit intoapache:trunkfrom
AndrewJSchofield wants to merge 1 commit intoapache:trunkfrom
Conversation
chia7712
reviewed
May 1, 2026
Member
chia7712
left a comment
There was a problem hiding this comment.
@AndrewJSchofield thanks for this cool feature!
| int nodeId = Integer.parseInt(node); | ||
| // When connecting to coordinators, the client uses large positive node ID | ||
| // values which do not match the target broker's node ID. Exclude those. | ||
| if (clusterId != null && nodeId > 0 && nodeId < Integer.MAX_VALUE / 2) { |
chia7712
reviewed
May 1, 2026
| public boolean isValid() { | ||
| if (version() >= 5) { | ||
| // Either cluster ID and node ID are both specified, or neither is. | ||
| if ((data.clusterId() == null && data.nodeId() != -1) || (data.clusterId() != null && data.nodeId() == -1)) { |
Member
There was a problem hiding this comment.
Should we document in ApiVersionsRequest.json that both fields must be defined together?
mingyen066
reviewed
May 2, 2026
| final String node = req.destination; | ||
| if (apiVersionsResponse.data().errorCode() != Errors.NONE.code()) { | ||
| if (req.request.version() == 0 || apiVersionsResponse.data().errorCode() != Errors.UNSUPPORTED_VERSION.code()) { | ||
| if (metadataRecoveryStrategy == MetadataRecoveryStrategy.REBOOTSTRAP && apiVersionsResponse.data().errorCode() == Errors.REBOOTSTRAP_REQUIRED.code()) { |
Collaborator
There was a problem hiding this comment.
Should we clean up the connection here like handleRebootstrap does?
kafka/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java
Lines 1117 to 1129 in 162b3a1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the implementation of
https://cwiki.apache.org/confluence/display/KAFKA/KIP-1242%3A+Detection+and+handling+of+misrouted+connections.
Adds cluster ID and node ID to the ApiVersionsRequest and checks it on
the broker.
Reviewers: Chia-Ping Tsai chia7712@gmail.com, Ming-Yen Chung
mingyen066@gmail.com