You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by el...@apache.org on 2020/07/27 11:24:10 UTC

[hadoop-ozone] branch storage-class created (now f339bc5)

This is an automated email from the ASF dual-hosted git repository.

elek pushed a change to branch storage-class
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git.


      at f339bc5  HDDS-4022. Ozone s3 API return 400 Bad Request for head-bucket for non existing bucket. (#1251)

This branch includes the following new commits:

     new f339bc5  HDDS-4022. Ozone s3 API return 400 Bad Request for head-bucket for non existing bucket. (#1251)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-commits-help@hadoop.apache.org


[hadoop-ozone] 01/01: HDDS-4022. Ozone s3 API return 400 Bad Request for head-bucket for non existing bucket. (#1251)

Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

elek pushed a commit to branch storage-class
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git

commit f339bc502d5d2db9e752046dfb568c26d93b1ad7
Author: Bharat Viswanadham <bh...@apache.org>
AuthorDate: Mon Jul 27 04:23:25 2020 -0700

    HDDS-4022. Ozone s3 API return 400 Bad Request for head-bucket for non existing bucket. (#1251)
---
 hadoop-ozone/dist/src/main/smoketest/s3/buckethead.robot      |  5 +++--
 .../org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java   |  8 +-------
 .../org/apache/hadoop/ozone/s3/endpoint/TestBucketHead.java   | 11 +++++++++--
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/hadoop-ozone/dist/src/main/smoketest/s3/buckethead.robot b/hadoop-ozone/dist/src/main/smoketest/s3/buckethead.robot
index 7666871..f3ecd01 100644
--- a/hadoop-ozone/dist/src/main/smoketest/s3/buckethead.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/s3/buckethead.robot
@@ -31,5 +31,6 @@ ${BUCKET}             generated
 Head Bucket not existent
     ${result} =         Execute AWSS3APICli     head-bucket --bucket ${BUCKET}
     ${result} =         Execute AWSS3APICli and checkrc      head-bucket --bucket ozonenosuchbucketqqweqwe  255
-                        Should contain          ${result}    Bad Request
-                        Should contain          ${result}    400
+                        Should contain          ${result}    404
+                        Should contain          ${result}    Not Found
+
diff --git a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
index fbb2dbf..87aa0ff 100644
--- a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
+++ b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java
@@ -31,7 +31,6 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Iterator;
@@ -250,12 +249,7 @@ public class BucketEndpoint extends EndpointBase {
       getBucket(bucketName);
     } catch (OS3Exception ex) {
       LOG.error("Exception occurred in headBucket", ex);
-      //TODO: use a subclass fo OS3Exception and catch it here.
-      if (ex.getCode().contains("NoSuchBucket")) {
-        return Response.status(Status.BAD_REQUEST).build();
-      } else {
-        throw ex;
-      }
+      throw ex;
     }
     return Response.ok().build();
   }
diff --git a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketHead.java b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketHead.java
index 6f991e6..18b4b2c 100644
--- a/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketHead.java
+++ b/hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestBucketHead.java
@@ -26,7 +26,10 @@ import org.apache.hadoop.ozone.OzoneConsts;
 import org.apache.hadoop.ozone.client.OzoneClient;
 import org.apache.hadoop.ozone.client.OzoneClientStub;
 
+import org.apache.hadoop.ozone.s3.exception.OS3Exception;
 import org.junit.Assert;
+
+import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
 import static org.junit.Assert.assertEquals;
 import org.junit.Before;
 import org.junit.Test;
@@ -60,7 +63,11 @@ public class TestBucketHead {
 
   @Test
   public void testHeadFail() throws Exception {
-    Response response = bucketEndpoint.head("unknownbucket");
-    Assert.assertEquals(400, response.getStatus());
+    try {
+      bucketEndpoint.head("unknownbucket");
+    } catch (OS3Exception ex) {
+      Assert.assertEquals(HTTP_NOT_FOUND, ex.getHttpCode());
+      Assert.assertEquals("NoSuchBucket", ex.getCode());
+    }
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-commits-help@hadoop.apache.org