[ 
https://issues.apache.org/jira/browse/HDDS-6903?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Duong updated HDDS-6903:
------------------------
    Description: 
Today, handling of user related exceptions, i.e. OMException, is inconsistent 
across endpoints. Sometimes, OMException are "manually" converted to 
OS3Exception, .e.g. 
[here][[https://github.com/duongnguyen0/ozone/blob/master/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java#L261-L261]]
 or 
[here][https://github.com/duongnguyen0/ozone/blob/master/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java#L654-L654],
 then correctly mapped to 4xx responses by 
[OS3ExceptionMapper][https://github.com/duongnguyen0/ozone/blob/master/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/exception/OS3ExceptionMapper.java#L35-L35].

But most of the time, OS3Exception are left unhandled and resolved to 500 - 
Internal Server Errors, e.g.  
{code:java}
sh-4.2$ aws s3api --endpoint http://localhost:9878 list-objects --bucket 
bucket_3
An error occurred (500) when calling the ListObjects operation (reached max 
retries: 4): Internal Server Error {code}
{code:java}
2022-06-17 02:33:19,466 [qtp1912821769-23] WARN server.HttpChannel: 
handleException /bucket_3 INVALID_BUCKET_NAME 
org.apache.hadoop.ozone.om.exceptions.OMException: Bucket or Volume name has an 
unsupported character : _2022-06-17 02:33:19,466 [qtp1912821769-23] WARN 
server.HttpChannelState: unhandled due to prior 
sendErrorjavax.servlet.ServletException: javax.servlet.ServletException: 
org.glassfish.jersey.server.ContainerException: INVALID_BUCKET_NAME 
org.apache.hadoop.ozone.om.exceptions.OMException: Bucket or Volume name has an 
unsupported character : _at 
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:162)at
 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)at
 org.eclipse.jetty.server.Server.handle(Server.java:516)at 
org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)at 
org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)at 
org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)at 
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)at 
org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)at
 org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)at 
org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)at
 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)at
 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)at
 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)at
 
org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:386)at
 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)at
 
org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)at
 java.base/java.lang.Thread.run(Thread.java:829)Caused by: 
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: 
INVALID_BUCKET_NAME org.apache.hadoop.ozone.om.exceptions.OMException: Bucket 
or Volume name has an unsupported character : _at 
org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:410)at 
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)at 
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
 {code}
We need to implement an exception mapper to map  to correct response codes.  ...

The complete mapping can be built based on the Exception/ResultCode and 
matching them with the [error codes from S3 
API|https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList].

 

 

  was:
Today, user related exception handlings are inconsistent across endpoints

 

This is due to the lack of an appropriate Jersey exception handler. Hence, all 
exceptions, including OMException, is considered as unhandled and thus internal 
server errors, e.g.
{code:java}
sh-4.2$ aws s3api --endpoint http://localhost:9878 list-objects --bucket 
bucket_3
An error occurred (500) when calling the ListObjects operation (reached max 
retries: 4): Internal Server Error {code}
We need to implement an exception mapper to map exceptions to correct response 
codes. Technically, this can be a Jersey level exception handler to avoid 
repeating the same logic in every endpoint.
{code:java}
OMException.ResultCodes.INVALID_BUCKET_NAME,
OMException.ResultCodes.INVALID_VOLUME_NAME,... => 400
OMException.ResultCodes.PERMISSION_DENIED => 403
...{code}
The complete mapping can be built based on the Exception/ResultCode and 
matching them with the [error codes from S3 
API|https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList].

 

 


> Correct mapping of exceptions to HTTP codes 
> --------------------------------------------
>
>                 Key: HDDS-6903
>                 URL: https://issues.apache.org/jira/browse/HDDS-6903
>             Project: Apache Ozone
>          Issue Type: Improvement
>          Components: S3
>            Reporter: Duong
>            Priority: Major
>
> Today, handling of user related exceptions, i.e. OMException, is inconsistent 
> across endpoints. Sometimes, OMException are "manually" converted to 
> OS3Exception, .e.g. 
> [here][[https://github.com/duongnguyen0/ozone/blob/master/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java#L261-L261]]
>  or 
> [here][https://github.com/duongnguyen0/ozone/blob/master/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java#L654-L654],
>  then correctly mapped to 4xx responses by 
> [OS3ExceptionMapper][https://github.com/duongnguyen0/ozone/blob/master/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/exception/OS3ExceptionMapper.java#L35-L35].
> But most of the time, OS3Exception are left unhandled and resolved to 500 - 
> Internal Server Errors, e.g.  
> {code:java}
> sh-4.2$ aws s3api --endpoint http://localhost:9878 list-objects --bucket 
> bucket_3
> An error occurred (500) when calling the ListObjects operation (reached max 
> retries: 4): Internal Server Error {code}
> {code:java}
> 2022-06-17 02:33:19,466 [qtp1912821769-23] WARN server.HttpChannel: 
> handleException /bucket_3 INVALID_BUCKET_NAME 
> org.apache.hadoop.ozone.om.exceptions.OMException: Bucket or Volume name has 
> an unsupported character : _2022-06-17 02:33:19,466 [qtp1912821769-23] WARN 
> server.HttpChannelState: unhandled due to prior 
> sendErrorjavax.servlet.ServletException: javax.servlet.ServletException: 
> org.glassfish.jersey.server.ContainerException: INVALID_BUCKET_NAME 
> org.apache.hadoop.ozone.om.exceptions.OMException: Bucket or Volume name has 
> an unsupported character : _at 
> org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:162)at
>  
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)at
>  org.eclipse.jetty.server.Server.handle(Server.java:516)at 
> org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)at 
> org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)at 
> org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)at 
> org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)at 
> org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)at
>  org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)at 
> org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)at 
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)at
>  
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)at
>  
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)at
>  
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)at
>  
> org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:386)at
>  
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)at
>  
> org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)at
>  java.base/java.lang.Thread.run(Thread.java:829)Caused by: 
> javax.servlet.ServletException: 
> org.glassfish.jersey.server.ContainerException: INVALID_BUCKET_NAME 
> org.apache.hadoop.ozone.om.exceptions.OMException: Bucket or Volume name has 
> an unsupported character : _at 
> org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:410)at
>  org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)at 
> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
>  {code}
> We need to implement an exception mapper to map  to correct response codes.  
> ...
> The complete mapping can be built based on the Exception/ResultCode and 
> matching them with the [error codes from S3 
> API|https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList].
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to