smengcl commented on code in PR #3594:
URL: https://github.com/apache/ozone/pull/3594#discussion_r924981452


##########
hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot:
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+*** Settings ***
+Documentation       S3 gateway test with aws cli
+Library             OperatingSystem
+Library             String
+Resource            ../commonlib.robot
+Resource            commonawslib.robot
+Test Timeout        5 minutes
+Suite Setup         Setup s3 tests
+
+*** Variables ***
+${ENDPOINT_URL}       http://s3g:9878
+${OZONE_TEST}         true
+${BUCKET}             generated
+
+*** Test Cases ***
+
+Head existing object
+                        Execute                            echo "Randomtext" > 
/tmp/testfile
+    ${result} =         Execute AWSS3APICli and checkrc    put-object --bucket 
${BUCKET} --key ${PREFIX}/putobject/key=value/f1 --body /tmp/testfile   0
+
+    ${result} =         Execute AWSS3APICli and checkrc    head-object 
--bucket ${BUCKET} --key ${PREFIX}/putobject/key=value/f1   0
+

Review Comment:
   Shall we clean up after the test when it's finished?



##########
hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot:
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+*** Settings ***
+Documentation       S3 gateway test with aws cli
+Library             OperatingSystem
+Library             String
+Resource            ../commonlib.robot
+Resource            commonawslib.robot
+Test Timeout        5 minutes
+Suite Setup         Setup s3 tests
+
+*** Variables ***
+${ENDPOINT_URL}       http://s3g:9878
+${OZONE_TEST}         true
+${BUCKET}             generated
+
+*** Test Cases ***
+
+Head existing object
+                        Execute                            echo "Randomtext" > 
/tmp/testfile
+    ${result} =         Execute AWSS3APICli and checkrc    put-object --bucket 
${BUCKET} --key ${PREFIX}/putobject/key=value/f1 --body /tmp/testfile   0
+
+    ${result} =         Execute AWSS3APICli and checkrc    head-object 
--bucket ${BUCKET} --key ${PREFIX}/putobject/key=value/f1   0
+
+Head object in non existing bucket
+    ${result} =         Execute AWSS3APICli and checkrc    head-object 
--bucket ${BUCKET}-non-exitst --key ${PREFIX}/putobject/key=value/f1   255

Review Comment:
   nit: typo?
   ```suggestion
       ${result} =         Execute AWSS3APICli and checkrc    head-object 
--bucket ${BUCKET}-non-existent --key ${PREFIX}/putobject/key=value/f1   255
   ```



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -230,6 +233,9 @@ public Response put(
         throw os3Exception;
       } else if (ex.getResult() == ResultCodes.PERMISSION_DENIED) {
         throw newError(S3ErrorTable.ACCESS_DENIED, keyPath, ex);
+      } else if (ex.getResult() == ResultCodes.BUCKET_NOT_FOUND
+          || ex.getResult() == ResultCodes.VOLUME_NOT_FOUND) {
+        throw newError(S3ErrorTable.NO_SUCH_BUCKET, bucketName, ex);

Review Comment:
   I get that S3 doesn't have the concept of `volume`.
   
   But in the rare case where OM throws `VOLUME_NOT_FOUND`, would it be helpful 
to log the message here in S3g that the client is trying to access a 
non-existent volume? to differentiate from `BUCKET_NOT_FOUND` for easier 
debugging -- Something might have gone horribly wrong like `s3v` or the tenant 
volume is completely missing.
   
   Or maybe just throw `NO_SUCH_VOLUME`? -- It is actual defined in the 
`S3ErrorTable` class though I'm not sure how other S3 clients would interpret 
this.



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -676,6 +698,9 @@ public Response 
completeMultipartUpload(@PathParam("bucket") String bucket,
             "considered as Unix Paths. A directory already exists with a " +
             "given KeyName caused failure for MPU");
         throw os3Exception;
+      } else if (ex.getResult() == ResultCodes.BUCKET_NOT_FOUND
+          || ex.getResult() == ResultCodes.VOLUME_NOT_FOUND) {
+        throw newError(S3ErrorTable.NO_SUCH_BUCKET, bucket, ex);

Review Comment:
   Same here?



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -204,7 +207,7 @@ public Response put(
         body = new SignedChunksInputStream(body);
       }
 
-      output = bucket.createKey(
+      output = getClientProtocol().createKey(volume.getName(), bucketName,

Review Comment:
   Maybe I didn't fully understand, is there a particular reason here not to 
use the `bucket` we got 20 lines ago? Is it any different?



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -422,6 +436,9 @@ public Response head(
         return Response.status(Status.NOT_FOUND).build();
       } else if (ex.getResult() == ResultCodes.PERMISSION_DENIED) {
         throw newError(S3ErrorTable.ACCESS_DENIED, keyPath, ex);
+      } else if (ex.getResult() == ResultCodes.BUCKET_NOT_FOUND ||
+                 ex.getResult() == ResultCodes.VOLUME_NOT_FOUND) {
+        throw newError(S3ErrorTable.NO_SUCH_BUCKET, bucketName, ex);

Review Comment:
   Same here?



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -451,14 +468,18 @@ public Response head(
    * @throws IOException
    * @throws OS3Exception
    */
-  private Response abortMultipartUpload(String bucket, String key, String
-      uploadId) throws IOException, OS3Exception {
+  private Response abortMultipartUpload(OzoneVolume volume, String bucket,
+                                        String key, String uploadId)
+      throws IOException, OS3Exception {
     try {
-      OzoneBucket ozoneBucket = getBucket(bucket);
-      ozoneBucket.abortMultipartUpload(key, uploadId);
+      getClientProtocol().abortMultipartUpload(volume.getName(), bucket,
+          key, uploadId);
     } catch (OMException ex) {
       if (ex.getResult() == ResultCodes.NO_SUCH_MULTIPART_UPLOAD_ERROR) {
         throw newError(S3ErrorTable.NO_SUCH_UPLOAD, uploadId, ex);
+      } else if (ex.getResult() == ResultCodes.BUCKET_NOT_FOUND
+          || ex.getResult() == ResultCodes.VOLUME_NOT_FOUND) {
+        throw newError(S3ErrorTable.NO_SUCH_BUCKET, bucket, ex);

Review Comment:
   Same here?



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -367,6 +376,9 @@ public Response get(
         throw newError(S3ErrorTable.NO_SUCH_KEY, keyPath, ex);
       } else if (ex.getResult() == ResultCodes.PERMISSION_DENIED) {
         throw newError(S3ErrorTable.ACCESS_DENIED, keyPath, ex);
+      } else if (ex.getResult() == ResultCodes.BUCKET_NOT_FOUND
+          || ex.getResult() == ResultCodes.VOLUME_NOT_FOUND) {
+        throw newError(S3ErrorTable.NO_SUCH_BUCKET, bucketName, ex);

Review Comment:
   Same here. `LOG.warn` on `VOLUME_NOT_FOUND`?



##########
hadoop-ozone/dist/src/main/smoketest/s3/objecthead.robot:
##########
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+*** Settings ***
+Documentation       S3 gateway test with aws cli
+Library             OperatingSystem
+Library             String
+Resource            ../commonlib.robot
+Resource            commonawslib.robot
+Test Timeout        5 minutes
+Suite Setup         Setup s3 tests
+
+*** Variables ***
+${ENDPOINT_URL}       http://s3g:9878
+${OZONE_TEST}         true
+${BUCKET}             generated
+
+*** Test Cases ***
+
+Head existing object
+                        Execute                            echo "Randomtext" > 
/tmp/testfile
+    ${result} =         Execute AWSS3APICli and checkrc    put-object --bucket 
${BUCKET} --key ${PREFIX}/putobject/key=value/f1 --body /tmp/testfile   0
+
+    ${result} =         Execute AWSS3APICli and checkrc    head-object 
--bucket ${BUCKET} --key ${PREFIX}/putobject/key=value/f1   0
+
+Head object in non existing bucket
+    ${result} =         Execute AWSS3APICli and checkrc    head-object 
--bucket ${BUCKET}-non-exitst --key ${PREFIX}/putobject/key=value/f1   255
+                        Should contain          ${result}    404
+                        Should contain          ${result}    Not Found
+
+Head non existing key
+    ${result} =         Execute AWSS3APICli and checkrc    head-object 
--bucket ${BUCKET} --key ${PREFIX}/non-exist   255

Review Comment:
   nit
   ```suggestion
       ${result} =         Execute AWSS3APICli and checkrc    head-object 
--bucket ${BUCKET} --key ${PREFIX}/non-existent   255
   ```



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