jsancio commented on code in PR #16735: URL: https://github.com/apache/kafka/pull/16735#discussion_r1704038461
########## raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java: ########## @@ -2153,6 +2175,84 @@ private CompletableFuture<RemoveRaftVoterResponseData> handleRemoveVoterRequest( ); } + private CompletableFuture<UpdateRaftVoterResponseData> handleUpdateVoterRequest( + RaftRequest.Inbound requestMetadata, + long currentTimeMs + ) { + UpdateRaftVoterRequestData data = (UpdateRaftVoterRequestData) requestMetadata.data(); + + if (!hasValidClusterId(data.clusterId())) { + return completedFuture( + RaftUtil.updateVoterResponse( + Errors.INCONSISTENT_CLUSTER_ID, + requestMetadata.listenerName(), + quorum.leaderAndEpoch(), + quorum.leaderEndpoints() + ) + ); + } + + Optional<Errors> leaderValidation = validateLeaderOnlyRequest(data.currentLeaderEpoch()); + if (leaderValidation.isPresent()) { + return completedFuture( + RaftUtil.updateVoterResponse( + leaderValidation.get(), + requestMetadata.listenerName(), + quorum.leaderAndEpoch(), + quorum.leaderEndpoints() + ) + ); + } + + Optional<ReplicaKey> voter = RaftUtil.updateVoterRequestVoterKey(data); + if (!voter.isPresent() || !voter.get().directoryId().isPresent()) { + return completedFuture( + RaftUtil.updateVoterResponse( + Errors.INVALID_REQUEST, + requestMetadata.listenerName(), + quorum.leaderAndEpoch(), + quorum.leaderEndpoints() + ) + ); + } + + Endpoints voterEndpoints = Endpoints.fromUpdateVoterRequest(data.listeners()); Review Comment: Hmm. Catching IllegalArgumentExceptions is not enough. Let me file an issue to audit all of the validation of the new RPCs: https://issues.apache.org/jira/browse/KAFKA-17264 -- 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-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org