You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "adoroszlai (via GitHub)" <gi...@apache.org> on 2026/04/20 18:03:06 UTC
[PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
adoroszlai opened a new pull request, #10097:
URL: https://github.com/apache/ozone/pull/10097
## What changes were proposed in this pull request?
Audit log shows only the last two elements of stack traces. For several failed S3 Gateway requests it is always the same:
```
... | ERROR | S3GAudit | ... | op=GET_BUCKET ... | ret=FAILURE | org.apache.hadoop.ozone.s3.exception.OS3Exception
at org.apache.hadoop.ozone.s3.exception.S3ErrorTable.newError(S3ErrorTable.java:192)
at org.apache.hadoop.ozone.s3.exception.S3ErrorTable.newError(S3ErrorTable.java:179)
```
due to two levels of `newError` calls.
This PR changes code to avod chained `newError` calls by creating `OS3Exception` in various `newError` implementations. Related changes to avoid duplication:
- Simplify `OS3Exception` creation:
- pass error code (`S3ErrorTable`) instead of separate variables
- also pass cause exception and `resource`
- remove unused constructors
- log from constructor instead of `newError`
- Create few more variants of `newError` to reduce `null` arguments in callers.
- Move `BucketEndpoint#translateException` to `S3ErrorTable` (renamed to `translateResultCode`), add more cases to `switch`. Change `ObjectEndpoint` to rely on result code translation in `newError`.
Related minor fix:
- Deleting non-existent keys returns success response (204), not an error. However, the audit log shows `ERROR` instead of `SUCCESS`, because `NOT_FOUND` error is handled in the outer `delete` method, not `handleDeleteRequest`. This is now moved to let audit log reflect the correct result.
https://issues.apache.org/jira/browse/HDDS-15000
## How was this patch tested?
Before:
```
| ERROR | S3GAudit | user=dlfknslnfslf | ip=172.18.0.6 | op=GET_BUCKET {"bucket":"[bucket-etqvtcowkf]","list-type":"[2]","max-keys":"[-1]","encoding-type":"[url]","x-amz-request-id":"1f772aef-ed39-41a6-b470-5fff0962422e","x-amz-id-2":"bn6THRxxaQso"} | ret=FAILURE | org.apache.hadoop.ozone.s3.exception.OS3Exception
at org.apache.hadoop.ozone.s3.exception.S3ErrorTable.newError(S3ErrorTable.java:192)
at org.apache.hadoop.ozone.s3.exception.S3ErrorTable.newError(S3ErrorTable.java:179)
```
After:
```
| ERROR | S3GAudit | user=dlfknslnfslf | ip=172.18.0.6 | op=GET_BUCKET {"bucket":"[bucket-mpqrnkuavm]","list-type":"[2]","max-keys":"[-1]","encoding-type":"[url]","x-amz-request-id":"28a04087-212e-4e82-bc3b-60976b690f86","x-amz-id-2":"0mVf1nwDd"} | ret=FAILURE | org.apache.hadoop.ozone.s3.exception.OS3Exception: Invalid Argument
at org.apache.hadoop.ozone.s3.exception.S3ErrorTable.newError(S3ErrorTable.java:261)
at org.apache.hadoop.ozone.s3.endpoint.BucketEndpoint.validateMaxKeys(BucketEndpoint.java:257)
```
Before:
```
| ERROR | S3GAudit | user=dlfknslnfslf | ip=172.18.0.6 | op=INIT_MULTIPART_UPLOAD {"bucket":"[bucket-etqvtcowkf]","path":"[ozone-test-6052266241/mpuWithLargeMetadata]","x-amz-request-id":"0e1c28c9-3451-498b-933e-2b668991216f","x-amz-id-2":"5kEMzckEG19","uploads":"[]"} | ret=FAILURE | org.apache.hadoop.ozone.s3.exception.OS3Exception
at org.apache.hadoop.ozone.s3.exception.S3ErrorTable.newError(S3ErrorTable.java:192)
at org.apache.hadoop.ozone.s3.exception.S3ErrorTable.newError(S3ErrorTable.java:179)
```
After:
```
| ERROR | S3GAudit | user=dlfknslnfslf | ip=172.18.0.6 | op=INIT_MULTIPART_UPLOAD {"bucket":"[bucket-mpqrnkuavm]","path":"[ozone-test-5385731147/mpuWithLargeMetadata]","x-amz-request-id":"41329a9a-7ab3-4fcb-8f41-06e130631a2e","x-amz-id-2":"S6IY69aIGOpGP","uploads":"[]"} | ret=FAILURE | org.apache.hadoop.ozone.s3.exception.OS3Exception: Illegal user defined metadata. Combined size exceeds the maximum allowed metadata size of 2KB
at org.apache.hadoop.ozone.s3.exception.S3ErrorTable.newError(S3ErrorTable.java:261)
at org.apache.hadoop.ozone.s3.endpoint.EndpointBase.getCustomMetadataFromHeaders(EndpointBase.java:315)
```
Before:
```
| ERROR | S3GAudit | user=dlfknslnfslf | ip=172.18.0.6 | op=DELETE_KEY {"bucket":"[bucket-etqvtcowkf]","path":"[thereisnosuchfile]",...} | ret=FAILURE | KEY_NOT_FOUND org.apache.hadoop.ozone.om.exceptions.OMException: Key not found
at org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB.handleError(OzoneManagerProtocolClientSideTranslatorPB.java:766)
at org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolClientSideTranslatorPB.deleteKey(OzoneManagerProtocolClientSideTranslatorPB.java:965)
```
After:
```
| INFO | S3GAudit | user=dlfknslnfslf | ip=172.18.0.6 | op=DELETE_KEY {"bucket":"[bucket-mpqrnkuavm]","path":"[thereisnosuchfile]",...} | ret=SUCCESS |
```
https://github.com/adoroszlai/ozone/actions/runs/24665673476
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3115375064
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/exception/OS3Exception.java:
##########
@@ -66,31 +66,16 @@ public OS3Exception() {
//Added for JaxB.
}
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param requestIdVal
- * @param resourceVal
- */
- public OS3Exception(String codeVal, String messageVal, String requestIdVal,
- String resourceVal) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.requestId = requestIdVal;
- this.resource = resourceVal;
- }
+ OS3Exception(S3ErrorTable error, Exception cause, String resource) {
+ super(error.getErrorMessage(), cause);
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param httpCode
- */
- public OS3Exception(String codeVal, String messageVal, int httpCode) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.httpCode = httpCode;
+ code = error.getCode();
+ errorMessage = error.getErrorMessage();
+ httpCode = error.getHttpCode();
+ this.resource = resource;
+
+ // logging in S3ErrorTable to respect any existing log level setting
+ S3ErrorTable.log(this);
Review Comment:
Can I check whether this is violating Safe Construction practices?
From Java Concurrency in Practice:
"An object is in a predictable, consistent state only after its constructor returns, so publishing an object from within its constructor can publish an incompletely constructed object. This is true even if the publication is the last statement in the constructor"
The workaround seem to use a public static factory method.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3115344628
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -573,7 +541,7 @@ public Response head(
OzoneKey key;
try {
if (S3Owner.hasBucketOwnershipVerificationConditions(getHeaders())) {
- OzoneBucket bucket = getBucket(bucketName);
+ OzoneBucket bucket = getVolume().getBucket(bucketName);
S3Owner.verifyBucketOwnerCondition(getHeaders(), bucketName, bucket.getOwner());
}
Review Comment:
Similar to `GET` and `PUT`, any plan to implement `handleHeadRequest` with `ObjectRequestContext`?
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/exception/OS3Exception.java:
##########
@@ -66,31 +66,16 @@ public OS3Exception() {
//Added for JaxB.
}
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param requestIdVal
- * @param resourceVal
- */
- public OS3Exception(String codeVal, String messageVal, String requestIdVal,
- String resourceVal) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.requestId = requestIdVal;
- this.resource = resourceVal;
- }
+ OS3Exception(S3ErrorTable error, Exception cause, String resource) {
+ super(error.getErrorMessage(), cause);
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param httpCode
- */
- public OS3Exception(String codeVal, String messageVal, int httpCode) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.httpCode = httpCode;
+ code = error.getCode();
+ errorMessage = error.getErrorMessage();
+ httpCode = error.getHttpCode();
+ this.resource = resource;
+
+ // logging in S3ErrorTable to respect any existing log level setting
+ S3ErrorTable.log(this);
Review Comment:
Can I check whether this is violating Safe Construction principle?
From Java Concurrency in Practice:
"An object is in a predictable, consistent state only after its constructor returns, so publishing an object from within its constructor can publish an incompletely constructed object. This is true even if the publication is the last statement in the constructor"
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -988,15 +935,13 @@ private Response createMultipartKey(OzoneVolume volume, OzoneBucket ozoneBucket,
}
if (ex.getResult() == ResultCodes.NO_SUCH_MULTIPART_UPLOAD_ERROR) {
throw newError(NO_SUCH_UPLOAD, uploadID, ex);
- } else if (isAccessDenied(ex)) {
- throw newError(S3ErrorTable.ACCESS_DENIED, bucketName + "/" + key, ex);
} else if (ex.getResult() == ResultCodes.INVALID_PART) {
OS3Exception os3Exception = newError(
S3ErrorTable.INVALID_ARGUMENT, String.valueOf(partNumber), ex);
os3Exception.setErrorMessage(ex.getMessage());
throw os3Exception;
}
- throw ex;
+ throw newError(bucketName, key, ex);
Review Comment:
Seems for ACCESS_DENIED the resource changes from `bucketName + "/" + key` to `key`?
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3115344628
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -573,7 +541,7 @@ public Response head(
OzoneKey key;
try {
if (S3Owner.hasBucketOwnershipVerificationConditions(getHeaders())) {
- OzoneBucket bucket = getBucket(bucketName);
+ OzoneBucket bucket = getVolume().getBucket(bucketName);
S3Owner.verifyBucketOwnerCondition(getHeaders(), bucketName, bucket.getOwner());
}
Review Comment:
Similar to `GET` and `PUT`, any plan to implement `handleHeadRequest` with `ObjectRequestContext`? Seems both `ObjectEndpoint` and `BucketEndpoint` have not implemented `handleHeadRequest` yet.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "priyeshkaratha (via GitHub)" <gi...@apache.org>.
priyeshkaratha commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3115023943
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/exception/S3ErrorTable.java:
##########
@@ -193,27 +195,87 @@ public int getHttpCode() {
return httpCode;
}
- public static OS3Exception newError(S3ErrorTable e, String resource) {
- return newError(e, resource, null);
+ /** Converts result code of @{code OMException} to {@code S3ErrorTable}, which
+ * should be thrown via {@link #newError(S3ErrorTable, String, Exception)}. */
+ public static S3ErrorTable translateResultCode(OMException ex) {
+ switch (ex.getResult()) {
+ case ACCESS_DENIED:
+ case INVALID_TOKEN:
+ case PERMISSION_DENIED:
+ return ACCESS_DENIED;
+ case ATOMIC_WRITE_CONFLICT:
+ return CONDITIONAL_REQUEST_CONFLICT;
+ case BUCKET_ALREADY_EXISTS:
+ return BUCKET_ALREADY_EXISTS;
+ case BUCKET_NOT_EMPTY:
+ return BUCKET_NOT_EMPTY;
+ case BUCKET_NOT_FOUND:
+ case VOLUME_NOT_FOUND:
+ return NO_SUCH_BUCKET;
+ case ENTITY_TOO_SMALL:
+ return ENTITY_TOO_SMALL;
+ case ETAG_MISMATCH:
+ case ETAG_NOT_AVAILABLE:
+ case KEY_ALREADY_EXISTS:
+ return PRECOND_FAILED;
+ case FILE_ALREADY_EXISTS:
+ return NO_OVERWRITE;
+ case INVALID_BUCKET_NAME:
+ return INVALID_BUCKET_NAME;
+ case INVALID_PART:
+ return INVALID_PART;
+ case INVALID_PART_ORDER:
+ return INVALID_PART_ORDER;
+ case INVALID_REQUEST:
+ return INVALID_REQUEST;
+ case KEY_NOT_FOUND:
+ return NO_SUCH_KEY;
+ case NOT_SUPPORTED_OPERATION:
+ return NOT_IMPLEMENTED;
+ case QUOTA_EXCEEDED:
+ return QUOTA_EXCEEDED;
+ default:
+ return INTERNAL_ERROR;
+ }
+ }
+
+ /** Same as {@link #newError(String, OMException)}, but uses {@code bucket} as the {@code resource}
+ * in case of {@link #NO_SUCH_BUCKET} error. */
+ public static OS3Exception newError(String bucket, String resource, OMException cause) {
+ S3ErrorTable errorCode = translateResultCode(cause);
+ return new OS3Exception(errorCode, cause, NO_SUCH_BUCKET == errorCode ? bucket : resource);
+ }
+
+ /** Creates new {@link OS3Exception} for {@link OMException} and {@code resource}. */
+ public static OS3Exception newError(@Nullable String resource, OMException cause) {
+ return new OS3Exception(translateResultCode(cause), cause, resource);
+ }
+
+ /** Creates new {@link OS3Exception} for {@link S3ErrorTable}. */
+ public static OS3Exception newError(S3ErrorTable errorCode) {
+ return new OS3Exception(errorCode, null, null);
+ }
+
+ /** Creates new {@link OS3Exception} for {@link S3ErrorTable} and {@code resource}. */
+ public static OS3Exception newError(S3ErrorTable errorCode, @Nullable String resource) {
+ return new OS3Exception(errorCode, null, resource);
+ }
+
+ /** Creates new {@link OS3Exception} for {@link S3ErrorTable}, {@code resource} and {@code cause}. */
Review Comment:
The Javadoc comment for this method is inaccurate as it mentions a resource parameter which is not present in this specific overload.
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/exception/S3ErrorTable.java:
##########
@@ -193,27 +195,87 @@ public int getHttpCode() {
return httpCode;
}
- public static OS3Exception newError(S3ErrorTable e, String resource) {
- return newError(e, resource, null);
+ /** Converts result code of @{code OMException} to {@code S3ErrorTable}, which
Review Comment:
There is a typo in the Javadoc tag. It should be {@code instead of @{code.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3115595397
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -573,7 +541,7 @@ public Response head(
OzoneKey key;
try {
if (S3Owner.hasBucketOwnershipVerificationConditions(getHeaders())) {
- OzoneBucket bucket = getBucket(bucketName);
+ OzoneBucket bucket = getVolume().getBucket(bucketName);
S3Owner.verifyBucketOwnerCondition(getHeaders(), bucketName, bucket.getOwner());
}
Review Comment:
Yes, we can do it later. `head()` is not too long, so it was lower priority.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 commented on PR #10097:
URL: https://github.com/apache/ozone/pull/10097#issuecomment-4293095447
Thanks @adoroszlai for the improvement and @priyeshkaratha @Russole for the reviews.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3115726357
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/exception/OS3Exception.java:
##########
@@ -66,31 +66,16 @@ public OS3Exception() {
//Added for JaxB.
}
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param requestIdVal
- * @param resourceVal
- */
- public OS3Exception(String codeVal, String messageVal, String requestIdVal,
- String resourceVal) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.requestId = requestIdVal;
- this.resource = resourceVal;
- }
+ OS3Exception(S3ErrorTable error, Exception cause, String resource) {
+ super(error.getErrorMessage(), cause);
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param httpCode
- */
- public OS3Exception(String codeVal, String messageVal, int httpCode) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.httpCode = httpCode;
+ code = error.getCode();
+ errorMessage = error.getErrorMessage();
+ httpCode = error.getHttpCode();
+ this.resource = resource;
+
+ // logging in S3ErrorTable to respect any existing log level setting
+ S3ErrorTable.log(this);
Review Comment:
Using a factory method brings back the original problem, stack trace would have "factory" and `newError` in first two levels.
We can move `log()` call to `newError`, which increases code duplication a bit.
Or we can increase stack trace elements from 3 to 4 in log config, which increases duplication in audit log:
https://github.com/apache/ozone/blob/0039ce6ea39287b4932945c15f268b7628d4dcea/hadoop-ozone/dist/src/shell/conf/s3g-audit-log4j2.properties#L76
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3115690292
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -988,15 +935,13 @@ private Response createMultipartKey(OzoneVolume volume, OzoneBucket ozoneBucket,
}
if (ex.getResult() == ResultCodes.NO_SUCH_MULTIPART_UPLOAD_ERROR) {
throw newError(NO_SUCH_UPLOAD, uploadID, ex);
- } else if (isAccessDenied(ex)) {
- throw newError(S3ErrorTable.ACCESS_DENIED, bucketName + "/" + key, ex);
} else if (ex.getResult() == ResultCodes.INVALID_PART) {
OS3Exception os3Exception = newError(
S3ErrorTable.INVALID_ARGUMENT, String.valueOf(partNumber), ex);
os3Exception.setErrorMessage(ex.getMessage());
throw os3Exception;
}
- throw ex;
+ throw newError(bucketName, key, ex);
Review Comment:
Yes, but this is consistent with other existing responses (code from `master`):
https://github.com/apache/ozone/blob/0039ce6ea39287b4932945c15f268b7628d4dcea/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java#L183
https://github.com/apache/ozone/blob/0039ce6ea39287b4932945c15f268b7628d4dcea/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java#L394
https://github.com/apache/ozone/blob/0039ce6ea39287b4932945c15f268b7628d4dcea/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java#L597
https://github.com/apache/ozone/blob/0039ce6ea39287b4932945c15f268b7628d4dcea/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java#L672
https://github.com/apache/ozone/blob/0039ce6ea39287b4932945c15f268b7628d4dcea/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java#L746
Using `bucket/key` seems better, not sure which one matches AWS. We can change it if needed in follow-up.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3116127924
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/exception/OS3Exception.java:
##########
@@ -66,31 +66,16 @@ public OS3Exception() {
//Added for JaxB.
}
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param requestIdVal
- * @param resourceVal
- */
- public OS3Exception(String codeVal, String messageVal, String requestIdVal,
- String resourceVal) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.requestId = requestIdVal;
- this.resource = resourceVal;
- }
+ OS3Exception(S3ErrorTable error, Exception cause, String resource) {
+ super(error.getErrorMessage(), cause);
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param httpCode
- */
- public OS3Exception(String codeVal, String messageVal, int httpCode) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.httpCode = httpCode;
+ code = error.getCode();
+ errorMessage = error.getErrorMessage();
+ httpCode = error.getHttpCode();
+ this.resource = resource;
+
+ // logging in S3ErrorTable to respect any existing log level setting
+ S3ErrorTable.log(this);
Review Comment:
> Using a factory method brings back the original problem, stack trace would have "factory" and newError in first two levels.
Good point. I'm OK to leave it be, we can watch out for any problem for safe construction.
> We can move log() call to newError, which increases code duplication a bit.
I'd prefer this, if you decided to change it.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #10097:
URL: https://github.com/apache/ozone/pull/10097#issuecomment-4293567353
Thanks @ivandika3, @priyeshkaratha, @Russole for the review.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3115375064
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/exception/OS3Exception.java:
##########
@@ -66,31 +66,16 @@ public OS3Exception() {
//Added for JaxB.
}
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param requestIdVal
- * @param resourceVal
- */
- public OS3Exception(String codeVal, String messageVal, String requestIdVal,
- String resourceVal) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.requestId = requestIdVal;
- this.resource = resourceVal;
- }
+ OS3Exception(S3ErrorTable error, Exception cause, String resource) {
+ super(error.getErrorMessage(), cause);
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param httpCode
- */
- public OS3Exception(String codeVal, String messageVal, int httpCode) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.httpCode = httpCode;
+ code = error.getCode();
+ errorMessage = error.getErrorMessage();
+ httpCode = error.getHttpCode();
+ this.resource = resource;
+
+ // logging in S3ErrorTable to respect any existing log level setting
+ S3ErrorTable.log(this);
Review Comment:
Can I check whether this is violating Safe Construction practices?
From Java Concurrency in Practice:
"An object is in a predictable, consistent state only after its constructor returns, so publishing an object from within its constructor can publish an incompletely constructed object. This is true even if the publication is the last statement in the constructor"
The workaround seem to be a private constructor.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3115375064
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/exception/OS3Exception.java:
##########
@@ -66,31 +66,16 @@ public OS3Exception() {
//Added for JaxB.
}
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param requestIdVal
- * @param resourceVal
- */
- public OS3Exception(String codeVal, String messageVal, String requestIdVal,
- String resourceVal) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.requestId = requestIdVal;
- this.resource = resourceVal;
- }
+ OS3Exception(S3ErrorTable error, Exception cause, String resource) {
+ super(error.getErrorMessage(), cause);
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param httpCode
- */
- public OS3Exception(String codeVal, String messageVal, int httpCode) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.httpCode = httpCode;
+ code = error.getCode();
+ errorMessage = error.getErrorMessage();
+ httpCode = error.getHttpCode();
+ this.resource = resource;
+
+ // logging in S3ErrorTable to respect any existing log level setting
+ S3ErrorTable.log(this);
Review Comment:
Can I check whether this is violating Safe Construction practices?
From Java Concurrency in Practice:
"An object is in a predictable, consistent state only after its constructor returns, so publishing an object from within its constructor can publish an incompletely constructed object. This is true even if the publication is the last statement in the constructor"
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-15000. Improve S3 audit log stack traces [ozone]
Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 merged PR #10097:
URL: https://github.com/apache/ozone/pull/10097
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org