ashishkumar50 commented on code in PR #6751:
URL: https://github.com/apache/ozone/pull/6751#discussion_r1625363227


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java:
##########
@@ -962,9 +970,19 @@ public void deleteKeys(OmDeleteKeys deleteKeys) throws 
IOException {
     OMRequest omRequest = createOMRequest(Type.DeleteKeys)
         .setDeleteKeysRequest(req)
         .build();
+    OMResponse omResponse = submitRequest(omRequest);
 
-    handleError(submitRequest(omRequest));
-
+    if (!quiet) {
+      handleError(omResponse);
+    }
+    List<OzoneManagerProtocolProtos.DeleteKeyError> errors =
+        omResponse.getDeleteKeysResponse().getErrorsList();

Review Comment:
   If not `quiet` no need to execute below code.



##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java:
##########
@@ -445,47 +447,50 @@ public MultiDeleteResponse 
multiDelete(@PathParam("bucket") String bucketName,
 
     OzoneBucket bucket = getBucket(bucketName);
     MultiDeleteResponse result = new MultiDeleteResponse();
+    Map<String, ErrorInfo> undeletedKeyResultMap;
+
     if (request.getObjects() != null) {
+      List<String> deleteKeys = new ArrayList<>();
       for (DeleteObject keyToDelete : request.getObjects()) {
-        long startNanos = Time.monotonicNowNanos();
-        try {
-          bucket.deleteKey(keyToDelete.getKey());
-          getMetrics().updateDeleteKeySuccessStats(startNanos);
-
-          if (!request.isQuiet()) {
-            result.addDeleted(new DeletedObject(keyToDelete.getKey()));
-          }
-        } catch (OMException ex) {
-          if (isAccessDenied(ex)) {
-            getMetrics().updateDeleteKeyFailureStats(startNanos);
-            result.addError(
-                new Error(keyToDelete.getKey(), "PermissionDenied",
-                    ex.getMessage()));
-          } else if (ex.getResult() != ResultCodes.KEY_NOT_FOUND) {
-            getMetrics().updateDeleteKeyFailureStats(startNanos);
-            result.addError(
-                new Error(keyToDelete.getKey(), "InternalError",
-                    ex.getMessage()));
-          } else {
-            if (!request.isQuiet()) {
-              result.addDeleted(new DeletedObject(keyToDelete.getKey()));
-            }
-            getMetrics().updateDeleteKeySuccessStats(startNanos);
+        deleteKeys.add(keyToDelete.getKey());
+      }
+      long startNanos = Time.monotonicNowNanos();
+      try {
+        undeletedKeyResultMap = bucket.deleteKeys(deleteKeys, true);
+        for (DeleteObject d : request.getObjects()) {
+          if (!request.isQuiet() && 
(!(undeletedKeyResultMap.containsKey(d.getKey())) ||
+              
undeletedKeyResultMap.get(d.getKey()).getCode().equals(ResultCodes.KEY_NOT_FOUND.name())))
 {
+            // if the key is not found, it is assumed to be successfully 
deleted
+            result.addDeleted(new DeletedObject(d.getKey()));
+          } else if (undeletedKeyResultMap.containsKey(d.getKey()) &&
+              
!undeletedKeyResultMap.get(d.getKey()).getCode().equals(ResultCodes.KEY_NOT_FOUND.name()))
 {
+            // All errors other than KEY_NOT_FOUND are returned
+            ErrorInfo error = undeletedKeyResultMap.get(d.getKey());
+            result.addError(new Error(d.getKey(), error.getCode(), 
error.getMessage()));
           }
-        } catch (Exception ex) {
-          getMetrics().updateDeleteKeyFailureStats(startNanos);
-          result.addError(
-              new Error(keyToDelete.getKey(), "InternalError",
-                  ex.getMessage()));
         }
+        getMetrics().updateDeleteKeySuccessStats(startNanos);
+      } catch (IOException ex) {
+        LOG.error("Delete key failed: {}", ex.getMessage());
+        getMetrics().updateDeleteKeyFailureStats(startNanos);
+        result.addError(
+            new Error("ALL", "InternalError",
+                ex.getMessage()));
       }
     }
+
+    Map<String, String> auditMap = getAuditParameters();
+    List<String> keys = new ArrayList<>();
+    for (DeleteObject d : request.getObjects()) {
+      keys.add(d.getKey());
+    }
+    auditMap.put("Keys", keys.toString());
     if (result.getErrors().size() != 0) {
       AUDIT.logWriteFailure(buildAuditMessageForFailure(s3GAction,
-          getAuditParameters(), new Exception("MultiDelete Exception")));
+          auditMap, new Exception("MultiDelete Exception")));

Review Comment:
   `auditMap` will contain all keys including success and failure as added 
above. We should either  add just failure keys or add failure/success keys 
separately.



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