adoroszlai opened a new pull request #3066:
URL: https://github.com/apache/ozone/pull/3066


   ## What changes were proposed in this pull request?
   
   S3 Gateway logs exception in `S3ErrorTable.newError`, but the stack trace is 
wrong.
   
   ```
   s3g_1       | <Error>
   s3g_1       |   <Code>InvalidBucketName</Code>
   s3g_1       |   <Message>The specified bucket is not valid.</Message>
   s3g_1       |   <Resource>a_b_c</Resource>
   s3g_1       |   <RequestId/>
   s3g_1       | </Error>
   s3g_1       |
   s3g_1       | org.apache.hadoop.ozone.s3.exception.OS3Exception
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.exception.S3ErrorTable.<clinit>(S3ErrorTable.java:88)
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.endpoint.EndpointBase.getBucket(EndpointBase.java:91)
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.endpoint.BucketEndpoint.head(BucketEndpoint.java:294)
   ```
   
   ```
   s3g_1       | <Error>
   s3g_1       |   <Code>NoSuchBucket</Code>
   s3g_1       |   <Message>The specified bucket does not exist</Message>
   s3g_1       |   <Resource>dont-exist</Resource>
   s3g_1       |   <RequestId/>
   s3g_1       | </Error>
   s3g_1       |
   s3g_1       | org.apache.hadoop.ozone.s3.exception.OS3Exception
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.exception.S3ErrorTable.<clinit>(S3ErrorTable.java:51)
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.endpoint.EndpointBase.getBucket(EndpointBase.java:91)
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.endpoint.BucketEndpoint.head(BucketEndpoint.java:294)
   ```
   
   Note that both errors have the same stack trace.  It always points to the 
operation that first accessed `S3ErrorTable` class (i.e. the one that triggered 
the first error, in this case a `head-bucket` operation).
   
   This change fixes the stack trace by passing the original exception, if 
available, to the method which logs, instead of using the predefined 
`OS3Exception`'s stack trace.
   
   https://issues.apache.org/jira/browse/HDDS-6257
   
   ## How was this patch tested?
   
   Set log level to debug:
   
   ```
   log4j.logger.org.apache.hadoop.ozone.s3.exception.S3ErrorTable=DEBUG
   ```
   
   Tested with the following commands.  Verified that stack traces are unique.
   
   ```
   aws s3api --endpoint http://s3g:9878 head-bucket --bucket dont-exist
   ```
   
   ```
   s3g_1       | 2022-02-09 14:41:46,981 [qtp690052870-22] DEBUG 
exception.S3ErrorTable: <?xml version="1.0" encoding="UTF-8"?>
   s3g_1       | <Error>
   s3g_1       |   <Code>NoSuchBucket</Code>
   s3g_1       |   <Message>The specified bucket does not exist</Message>
   s3g_1       |   <Resource>dont-exist</Resource>
   s3g_1       |   <RequestId/>
   s3g_1       | </Error>
   s3g_1       |
   s3g_1       | BUCKET_NOT_FOUND 
org.apache.hadoop.ozone.om.exceptions.OMException: Bucket not found
   s3g_1       |    at 
org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB.handleError(OzoneManagerProtocolClientSideTranslatorPB.java:654)
   s3g_1       |    at 
org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB.getBucketInfo(OzoneManagerProtocolClientSideTranslatorPB.java:503)
   s3g_1       |    at 
org.apache.hadoop.ozone.client.rpc.RpcClient.getBucketDetails(RpcClient.java:771)
   s3g_1       |    at 
org.apache.hadoop.ozone.client.OzoneVolume.getBucket(OzoneVolume.java:406)
   s3g_1       |    at 
org.apache.hadoop.ozone.client.ObjectStore.getS3Bucket(ObjectStore.java:122)
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.endpoint.EndpointBase.getBucket(EndpointBase.java:89)
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.endpoint.BucketEndpoint.head(BucketEndpoint.java:293)
   ```
   
   ```
   aws s3api --endpoint http://s3g:9878 delete-bucket --bucket dont-exist
   ```
   
   ```
   s3g_1       | 2022-02-09 14:42:29,766 [qtp690052870-16] DEBUG 
exception.S3ErrorTable: <?xml version="1.0" encoding="UTF-8"?>
   s3g_1       | <Error>
   s3g_1       |   <Code>NoSuchBucket</Code>
   s3g_1       |   <Message>The specified bucket does not exist</Message>
   s3g_1       |   <Resource>dont-exist</Resource>
   s3g_1       |   <RequestId/>
   s3g_1       | </Error>
   s3g_1       |
   s3g_1       | BUCKET_NOT_FOUND 
org.apache.hadoop.ozone.om.exceptions.OMException: Bucket not exists
   s3g_1       |    at 
org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB.handleError(OzoneManagerProtocolClientSideTranslatorPB.java:654)
   s3g_1       |    at 
org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB.deleteBucket(OzoneManagerProtocolClientSideTranslatorPB.java:856)
   s3g_1       |    at 
org.apache.hadoop.ozone.client.rpc.RpcClient.deleteBucket(RpcClient.java:756)
   s3g_1       |    at 
org.apache.hadoop.ozone.client.OzoneVolume.deleteBucket(OzoneVolume.java:444)
   s3g_1       |    at 
org.apache.hadoop.ozone.client.ObjectStore.deleteS3Bucket(ObjectStore.java:133)
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.endpoint.EndpointBase.deleteS3Bucket(EndpointBase.java:140)
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.endpoint.BucketEndpoint.delete(BucketEndpoint.java:308)
   ```
   
   ```
   aws s3api --endpoint http://s3g:9878 create-bucket --bucket 'a_b_c'
   ```
   
   ```
   s3g_1       | 2022-02-09 14:43:02,028 [qtp690052870-17] DEBUG 
exception.S3ErrorTable: <?xml version="1.0" encoding="UTF-8"?>
   s3g_1       | <Error>
   s3g_1       |   <Code>InvalidBucketName</Code>
   s3g_1       |   <Message>The specified bucket is not valid.</Message>
   s3g_1       |   <Resource>a_b_c</Resource>
   s3g_1       |   <RequestId/>
   s3g_1       | </Error>
   s3g_1       |
   s3g_1       | INVALID_BUCKET_NAME 
org.apache.hadoop.ozone.om.exceptions.OMException: Bucket or Volume name has an 
unsupported character : _
   s3g_1       |    at 
org.apache.hadoop.ozone.client.rpc.RpcClient.verifyBucketName(RpcClient.java:582)
   s3g_1       |    at 
org.apache.hadoop.ozone.client.rpc.RpcClient.createBucket(RpcClient.java:521)
   s3g_1       |    at 
org.apache.hadoop.ozone.client.rpc.RpcClient.createBucket(RpcClient.java:512)
   s3g_1       |    at 
org.apache.hadoop.ozone.client.OzoneVolume.createBucket(OzoneVolume.java:385)
   s3g_1       |    at 
org.apache.hadoop.ozone.client.ObjectStore.createS3Bucket(ObjectStore.java:118)
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.endpoint.EndpointBase.createS3Bucket(EndpointBase.java:119)
   s3g_1       |    at 
org.apache.hadoop.ozone.s3.endpoint.BucketEndpoint.put(BucketEndpoint.java:240)
   ```
   
   ```
   ozone sh bucket create /s3v/bucket1
   ozone sh key put /s3v/bucket1/key1 /etc/passwd
   aws s3api --endpoint http://s3g:9878 get-object --bucket bucket1 --key key1 
--range bytes=10000-10000 /dev/null
   ```
   
   ```
   s3g_1       | 2022-02-09 14:56:33,771 [qtp690052870-22] DEBUG 
exception.S3ErrorTable: <?xml version="1.0" encoding="UTF-8"?>
   s3g_1       | <Error>
   s3g_1       |   <Code>InvalidRange</Code>
   s3g_1       |   <Message>The requested range is not satisfiable</Message>
   s3g_1       |   <Resource>bytes=10000-10000</Resource>
   s3g_1       |   <RequestId/>
   s3g_1       | </Error>
   ```
   
   CI:
   https://github.com/adoroszlai/hadoop-ozone/actions/runs/1818745426


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

Reply via email to