You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/05/02 11:19:03 UTC

[GitHub] [kafka] divijvaidya commented on a diff in pull request #12106: KAFKA-13861: Fix the validateOnly behavior for CreatePartitions requests in KRaft mode

divijvaidya commented on code in PR #12106:
URL: https://github.com/apache/kafka/pull/12106#discussion_r862747446


##########
core/src/main/scala/kafka/server/ControllerApis.scala:
##########
@@ -767,7 +767,7 @@ class ControllerApis(val requestChannel: RequestChannel,
           setErrorCode(TOPIC_AUTHORIZATION_FAILED.code))
       }
     }
-    controller.createPartitions(context, topics).thenApply { results =>
+    controller.createPartitions(context, topics, request.validateOnly()).thenApply { results =>

Review Comment:
   nit
   
   you don't need the parenthesis in scala here. Simply `request.validateOnly` would work.



##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -1664,13 +1664,14 @@ public CompletableFuture<UpdateFeaturesResponseData> updateFeatures(
     @Override
     public CompletableFuture<List<CreatePartitionsTopicResult>> createPartitions(

Review Comment:
   You can handle the `validateOnly` here and downstream function calls do not have to know about it. This would greatly simplify the code because now `ReplicationControl` does not have to deal with parsing the result and handling the `validateOnly` flag
   
   e.g. this function implementation would change to
   ```
           if (topics.isEmpty()) {
               return CompletableFuture.completedFuture(Collections.emptyList());
           }
   
           return appendWriteEvent("createPartitions", context.deadlineNs(), () -> {
               final ControllerResult<List<CreatePartitionsTopicResult>> result = replicationControl.createPartitions(topics);
               return validateOnly ? result.withoutRecords() : result;
           });
   ```



-- 
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