-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-11013. Ensure version is always set in ContainerCommandRequestProto #6812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ion in one centralised function Change-Id: I540e518819db3ebfec1aca5b3a31d1b5ba5fee41
Change-Id: Id5abeebc078d39d15d516cf804dcdaaa3ed2467c Change-Id: Ic5a87d9e696a462cfe92ff35a0068dfeba97541c
hemantk-12
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @swamirishi for the patch. In general, change looks good to me. Left a comment about one change in ClientVersion.
nit: I don't think it is a good idea to provide a helper function on top of builder. I guess you have done it this way to make the version mandatory field and ContainerCommandRequestProto.newBuilder() is generated by protobuf.
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/ClientVersion.java
Outdated
Show resolved
Hide resolved
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/storage/ContainerProtocolCalls.java
Outdated
Show resolved
Hide resolved
Change-Id: I8936e48570d75052a32c40a9aee751628b753585
Yeah I wanted to mandate client versions are being set to the latest value on all the request. I don't think there is a programatic way of doing this in protobuf. From what I know we can only set a constant value in proto file. Moreover server side and client side handling is going to be different in this patch. #6779 |
|
We can deprecate this method call, when we would stop supporting older clients on the server side. |
hemantk-12
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM+1.
adoroszlai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @swamirishi for extracting this.
There are two leftover calls to newBuilder in ContainerProtocolCalls (echo and readContainerFromAllNodes) and two in TestHddsDispatcher (newPutSmallFile and getWriteChunkRequest0).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again @swamirishi for the patch.
One question: instead of replacing all the calls, how about setting version in sendCommand(Async)? That would simplify this change a whole lot. It would also avoid potential problems caused by accidentally using the plain builder instead of the one created by the central functions. This should be done in both client classes.
| public static ContainerCommandRequestProto.Builder getContainerCommandRequestProtoBuilder( | ||
| ContainerCommandRequestProto req, int version) { | ||
| return (req == null ? | ||
| ContainerCommandRequestProto.newBuilder() : ContainerCommandRequestProto.newBuilder(req)).setVersion(version); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would have to build an object again there. Is it something we should do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that is the case we should just send a builder than sending the request object. That is also one viable change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or we can just add a validation check and throw an exception if the version is not set.
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java
Outdated
Show resolved
Hide resolved
|
|
||
| ContainerCommandRequestProto finalPayload = | ||
| ContainerCommandRequestProto.newBuilder(request) | ||
| ContainerCommandRequestProto finalPayload = getContainerCommandRequestProtoBuilder(request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also set version conditionally here.
Change-Id: I24026f8f2863c1b0501c781452c269a09a7c3b7c
Change-Id: I510d453b900c945814c4d665dfcee5aa14ab0476
Change-Id: I5524a82d0c77a9c01a9034cb4cd0cd2ae577b3f8
Change-Id: Icca0406b6cd1cf9edb8bd0dc350a537a397737a3
Change-Id: Ie101e536af7728528036a042437ff23896c3f34e
hemantk-12
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
| List<DatanodeDetails> datanodeList = pipeline.getNodes(); | ||
| HashMap<DatanodeDetails, CompletableFuture<ContainerCommandResponseProto>> | ||
| futureHashMap = new HashMap<>(); | ||
| ContainerCommandRequestProto.Builder builder = ContainerCommandRequestProto.newBuilder(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: create a helper function something likegetVersionRequest() and reuse it in other places.
adoroszlai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @swamirishi for updating the patch. I think it's much simpler now. Only few nits picked.
| if (!request.hasVersion()) { | ||
| builder.setVersion(ClientVersion.CURRENT.toProtoValue()); | ||
| } | ||
| ContainerCommandRequestProto finalRequest = builder.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we only conditionally need to create newBuilder() and then build().
| return TracingUtil.executeInNewSpan(spanName, | ||
| () -> { | ||
| ContainerCommandRequestProto finalPayload = | ||
| ContainerCommandRequestProto.Builder finalPayload = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: finalPayload can be renamed to builder.
| try (Scope ignored = GlobalTracer.get().activateSpan(span)) { | ||
|
|
||
| ContainerCommandRequestProto finalPayload = | ||
| ContainerCommandRequestProto.Builder finalPayload = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: finalPayload can be renamed to builder.
| public XceiverClientReply sendCommandAsync( | ||
| ContainerCommandRequestProto request | ||
| ) { | ||
| final ContainerCommandRequestProto.Builder finalRequest = ContainerCommandRequestProto.newBuilder(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: finalRequest can be renamed to builder.
| final ContainerCommandRequestProto.Builder finalRequest = ContainerCommandRequestProto.newBuilder(request); | ||
| if (!request.hasVersion()) { | ||
| finalRequest.setVersion(ClientVersion.CURRENT.toProtoValue()); | ||
| } | ||
| request = finalRequest.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we only conditionally need to create newBuilder() and then build().
| final Builder builder = | ||
| ContainerCommandRequestProto.newBuilder() | ||
| ClientVersion clientVersion, ContainerProtos.Type cmdType, int replicaIndex) { | ||
| final Builder builder = ContainerCommandRequestProto.newBuilder().setVersion(clientVersion.toProtoValue()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
| final Builder builder = ContainerCommandRequestProto.newBuilder().setVersion(clientVersion.toProtoValue()) | |
| final Builder builder = ContainerCommandRequestProto.newBuilder() | |
| .setVersion(clientVersion.toProtoValue()) |
Change-Id: If914929863aba7e7123f3daf73e682e1416967b1
adoroszlai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @swamirishi for updating the patch, LGTM.
|
Thank your for the review @hemantk-12 @adoroszlai |
…oto (apache#6812) (cherry picked from commit 81bc179)
…oto (apache#6812) (cherry picked from commit 81bc179)
…oto (apache#6812) (cherry picked from commit 81bc179)
…oto (apache#6812) (cherry picked from commit 81bc179)
…andRequestProto (apache#6812) (cherry picked from commit 81bc179) Change-Id: I1a11a59f7d245578ff233a29c9b120974c5a413d
What changes were proposed in this pull request?
Setting ClientVersion in the ContainerCommandRequestProto object in XceiverGrpcClient send method, to ensure client version is always set on the request object.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-11013
How was this patch tested?
Existing Unit test, no functional change.