adoroszlai commented on code in PR #6812:
URL: https://github.com/apache/ozone/pull/6812#discussion_r1639337653


##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java:
##########
@@ -337,8 +338,7 @@ private XceiverClientReply sendCommandWithTraceIDAndRetry(
 
     return TracingUtil.executeInNewSpan(spanName,
         () -> {
-          ContainerCommandRequestProto finalPayload =
-              ContainerCommandRequestProto.newBuilder(request)
+          ContainerCommandRequestProto finalPayload = 
getContainerCommandRequestProtoBuilder(request)
                   .setTraceID(TracingUtil.exportCurrentSpan()).build();

Review Comment:
   Would this work?
   
   ```suggestion
             ContainerCommandRequestProto.Builder builder = 
getContainerCommandRequestProtoBuilder(request)
                 .setTraceID(TracingUtil.exportCurrentSpan());
             if (!request.hasVersion()) {
               builder.setVersion(ClientVersion.CURRENT.toProtoValue());
             }
             return sendCommandWithRetry(builder.build(), validators);
   ```



##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java:
##########
@@ -490,8 +490,7 @@ public XceiverClientReply sendCommandAsync(
 
     try (Scope ignored = GlobalTracer.get().activateSpan(span)) {
 
-      ContainerCommandRequestProto finalPayload =
-          ContainerCommandRequestProto.newBuilder(request)
+      ContainerCommandRequestProto finalPayload = 
getContainerCommandRequestProtoBuilder(request)

Review Comment:
   Also set version conditionally here.



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/storage/ContainerProtocolCalls.java:
##########
@@ -97,6 +98,28 @@ public final class ContainerProtocolCalls  {
   private ContainerProtocolCalls() {
   }
 
+  /**
+   * Creates a ContainerCommandRequestProto with version set.
+   */
+  public static ContainerCommandRequestProto.Builder 
getContainerCommandRequestProtoBuilder(int version) {
+    return getContainerCommandRequestProtoBuilder(null, version);
+  }
+
+  public static ContainerCommandRequestProto.Builder 
getContainerCommandRequestProtoBuilder() {
+    return getContainerCommandRequestProtoBuilder(null, 
ClientVersion.CURRENT.toProtoValue());
+  }
+
+  public static ContainerCommandRequestProto.Builder 
getContainerCommandRequestProtoBuilder(
+      ContainerCommandRequestProto req, int version) {
+    return (req == null ?
+        ContainerCommandRequestProto.newBuilder() : 
ContainerCommandRequestProto.newBuilder(req)).setVersion(version);
+  }

Review Comment:
   `req` may already have `version` set.  `newBuilder(req)` preserves that in 
the builder, but `setVersion` overwrites it.  This is a problem if called via 
`getContainerCommandRequestProtoBuilder(req)`, without explicit version.



-- 
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: issues-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to