errose28 commented on code in PR #3262:
URL: https://github.com/apache/ozone/pull/3262#discussion_r853271941
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/StorageContainerLocationProtocolServerSideTranslatorPB.java:
##########
@@ -172,9 +191,185 @@ public ScmContainerLocationResponse
submitRequest(RpcController controller,
scm.getScmHAManager().getRatisServer().triggerNotLeaderException(),
scm.getClientRpcPort(), scm.getScmId());
}
- return dispatcher
+ // After the request interceptor (now validator) framework is extended to
+ // this server interface, this should be removed and solved via new
+ // annotated interceptors.
+ boolean checkResponseForECRepConfig = false;
+ if (request.getVersion() <
+ ClientVersion.ERASURE_CODING_SUPPORT.toProtoValue()) {
+ if (request.getCmdType() == GetContainer
+ || request.getCmdType() == ListContainer
+ || request.getCmdType() == GetContainerWithPipeline
+ || request.getCmdType() == GetContainerWithPipelineBatch
+ || request.getCmdType() == GetExistContainerWithPipelinesInBatch
+ || request.getCmdType() == ListPipelines
+ || request.getCmdType() == GetPipeline) {
+
+ checkResponseForECRepConfig = true;
+ }
+ }
+ ScmContainerLocationResponse response = dispatcher
.processRequest(request, this::processRequest, request.getCmdType(),
request.getTraceID());
+ if (checkResponseForECRepConfig) {
+ switch (response.getCmdType()) {
+ case GetContainer:
+ disallowECReplicationConfigInGetContainerResponse(response);
+ break;
+ case ListContainer:
+ disallowECReplicationConfigInListContainerResponse(response);
+ break;
+ case GetContainerWithPipeline:
+
disallowECReplicationConfigInGetContainerWithPipelineResponse(response);
+ break;
+ case GetContainerWithPipelineBatch:
+ disallowECReplicationConfigInGetContainerWithPipelineBatchResponse(
+ response);
+ break;
+ case GetExistContainerWithPipelinesInBatch:
+
disallowECReplicationConfigInGetExistContainerWithPipelineBatchResponse(
+ response);
+ break;
+ case ListPipelines:
+ disallowECReplicationConfigInListPipelinesResponse(response);
+ break;
+ case GetPipeline:
+ disallowECReplicationConfigInGetPipelineResponse(response);
+ break;
+ default:
+ }
+ }
+ return response;
+ }
+
+ private void disallowECReplicationConfigInListContainerResponse(
+ ScmContainerLocationResponse response) throws ServiceException {
+ if (!response.hasScmListContainerResponse()) {
+ return;
+ }
+ for (HddsProtos.ContainerInfoProto containerInfo :
+ response.getScmListContainerResponse().getContainersList()) {
+ if (containerInfo.hasEcReplicationConfig()) {
+ throw new ServiceException(ERROR_LIST_CONTAINS_EC_REPLICATION_CONFIG);
+ }
+ }
+ }
+
+ private void disallowECReplicationConfigInGetContainerResponse(
+ ScmContainerLocationResponse response) throws ServiceException {
+ if (!response.hasGetContainerResponse()) {
+ return;
+ }
+ if (!response.getGetContainerResponse().hasContainerInfo()) {
+ return;
+ }
+ if (response.getGetContainerResponse().getContainerInfo()
+ .hasEcReplicationConfig()) {
+ throw new
ServiceException(ERROR_RESPONSE_CONTAINS_EC_REPLICATION_CONFIG);
+ }
+ }
+
+ private void disallowECReplicationConfigInGetContainerWithPipelineResponse(
+ ScmContainerLocationResponse response) throws ServiceException {
+ if (!response.hasGetContainerWithPipelineResponse()) {
+ return;
+ }
+ if (!response.getGetContainerWithPipelineResponse()
+ .hasContainerWithPipeline()) {
+ return;
+ }
+ if (response.getGetContainerWithPipelineResponse()
+ .getContainerWithPipeline().hasContainerInfo()) {
+ HddsProtos.ContainerInfoProto containerInfo =
+ response.getGetContainerWithPipelineResponse()
+ .getContainerWithPipeline().getContainerInfo();
+ if (containerInfo.hasEcReplicationConfig()) {
+ throw new ServiceException(
Review Comment:
UNSUPPORTED_OPERATION would be good. I am ok with INTERNAL_ERROR for now.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]