-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-4519. Return forbidden instead of interval server error from s3g… #1642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -209,6 +209,9 @@ public Response put( | |
| " considered as Unix Paths. Path has Violated FS Semantics " + | ||
| "which caused put operation to fail."); | ||
| throw os3Exception; | ||
| } else if ((((OMException) ex).getResult() == | ||
| ResultCodes.PERMISSION_DENIED)) { | ||
| throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, keyPath); | ||
| } | ||
| } | ||
| throw ex; | ||
|
|
@@ -320,6 +323,8 @@ public Response get( | |
| if (ex.getResult() == ResultCodes.KEY_NOT_FOUND) { | ||
| throw S3ErrorTable.newError(S3ErrorTable | ||
| .NO_SUCH_KEY, keyPath); | ||
| } else if (ex.getResult() == ResultCodes.PERMISSION_DENIED) { | ||
| throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, keyPath); | ||
| } else { | ||
| throw ex; | ||
| } | ||
|
|
@@ -357,6 +362,8 @@ public Response head( | |
| if (ex.getResult() == ResultCodes.KEY_NOT_FOUND) { | ||
| // Just return 404 with no content | ||
| return Response.status(Status.NOT_FOUND).build(); | ||
| } else if (ex.getResult() == ResultCodes.PERMISSION_DENIED) { | ||
| throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, keyPath); | ||
| } else { | ||
| throw ex; | ||
| } | ||
|
|
@@ -426,6 +433,8 @@ public Response delete( | |
| } else if (ex.getResult() == ResultCodes.KEY_NOT_FOUND) { | ||
| //NOT_FOUND is not a problem, AWS doesn't throw exception for missing | ||
| // keys. Just return 204 | ||
| } else if (ex.getResult() == ResultCodes.PERMISSION_DENIED) { | ||
| throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, keyPath); | ||
| } else { | ||
| throw ex; | ||
| } | ||
|
|
@@ -474,9 +483,12 @@ public Response initializeMultipartUpload( | |
|
|
||
| return Response.status(Status.OK).entity( | ||
| multipartUploadInitiateResponse).build(); | ||
| } catch (IOException ex) { | ||
| } catch (OMException ex) { | ||
| LOG.error("Error in Initiate Multipart Upload Request for bucket: {}, " + | ||
| "key: {}", bucket, key, ex); | ||
| if (ex.getResult() == ResultCodes.PERMISSION_DENIED) { | ||
| throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, key); | ||
| } | ||
| throw ex; | ||
| } | ||
| } | ||
|
|
@@ -619,6 +631,9 @@ private Response createMultipartKey(String bucket, String key, long length, | |
| if (ex.getResult() == ResultCodes.NO_SUCH_MULTIPART_UPLOAD_ERROR) { | ||
| throw S3ErrorTable.newError(NO_SUCH_UPLOAD, | ||
| uploadID); | ||
| } else if (ex.getResult() == ResultCodes.PERMISSION_DENIED) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to have a common helper that does the OM result code => s3 error translation?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In long term,it's good to have such a mapping table. |
||
| throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, | ||
| bucket + "/" + key); | ||
| } | ||
| throw ex; | ||
| } | ||
|
|
@@ -675,6 +690,9 @@ private Response listParts(String bucket, String key, String uploadID, | |
| if (ex.getResult() == ResultCodes.NO_SUCH_MULTIPART_UPLOAD_ERROR) { | ||
| throw S3ErrorTable.newError(NO_SUCH_UPLOAD, | ||
| uploadID); | ||
| } else if (ex.getResult() == ResultCodes.PERMISSION_DENIED) { | ||
| throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, | ||
| bucket + "/" + key + "/" + uploadID); | ||
| } | ||
| throw ex; | ||
| } | ||
|
|
@@ -760,6 +778,9 @@ private CopyObjectResponse copyObject(String copyHeader, | |
| throw S3ErrorTable.newError(S3ErrorTable.NO_SUCH_KEY, sourceKey); | ||
| } else if (ex.getResult() == ResultCodes.BUCKET_NOT_FOUND) { | ||
| throw S3ErrorTable.newError(S3ErrorTable.NO_SUCH_BUCKET, sourceBucket); | ||
| } else if (ex.getResult() == ResultCodes.PERMISSION_DENIED) { | ||
| throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, | ||
| destBucket + "/" + destkey); | ||
| } | ||
| throw ex; | ||
| } finally { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason for throwing RuntimeException here?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the current code is doing the same. Do you think we need to change here to handle error? (Not related to this PR BTW). I see the reason as hasNext() does not throw any exception.