jsancio commented on code in PR #16735: URL: https://github.com/apache/kafka/pull/16735#discussion_r1704031646
########## 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()); + if (!voterEndpoints.address(channel.listenerName()).isPresent()) { + return completedFuture( + RaftUtil.updateVoterResponse( + Errors.INVALID_REQUEST, Review Comment: I thought about this before. The ErrorMessage field is a human readable message meant to be displayed to the end user. This is why the admin RPCs (AddVoter and RemoveVoter) have the additional ErrorMessage field. UpdateVoter is an internal RPC. Internal RPCs don't tend to have a human readable error message. -- 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