atharvaHJoshi opened a new pull request, #23778: URL: https://github.com/apache/kafka/pull/23778
When a raft request carries a cluster id that does not match the local cluster id, `KafkaRaftClient` rejects it with `INCONSISTENT_CLUSTER_ID`, but the two ids being compared are never surfaced. As reported in KAFKA-19022, this makes it impossible to tell from the logs whether the local id or the incoming id is empty/incorrect during a ZK-to-KRaft migration. This change logs both ids from `hasValidClusterId`, which is the single validation point used by every request type (`Vote`, `BeginQuorumEpoch`, `EndQuorumEpoch`, `Fetch`, `FetchSnapshot`, `AddRaftVoter`, `RemoveRaftVoter`, `UpdateRaftVoter`): ``` Received request with cluster id "<requestClusterId>", which does not match the local cluster id "<localClusterId>" ``` This is a diagnostics-only change. No wire protocol or response schema is modified, so the KIP that would be required to return these ids in the responses (as discussed on the ticket) is not needed. Note: the existing `AddRaftVoter`/`UpdateRaftVoter` paths already return an error message in the response; this change additionally logs for all request types. ### Testing - Added `KafkaRaftClientTest#testInconsistentClusterIdLogsComparedClusterIds`, which delivers a vote request with an invalid cluster id and asserts the comparison is logged. - Ran the full `KafkaRaftClientTest` plus `:raft:spotlessCheck`, `:raft:checkstyleMain` and `:raft:checkstyleTest` — all pass. - Added `org.apache.logging.log4j.Level` to the raft allow-list in `checkstyle/import-control.xml` (matching other modules) so the test can set the class log level. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
