adoroszlai commented on code in PR #8251:
URL: https://github.com/apache/ozone/pull/8251#discussion_r2048236972


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -627,52 +670,78 @@ public HddsProtos.Node queryNode(UUID uuid)
             .build();
       }
     } catch (NodeNotFoundException e) {
-      throw new IOException(
+      IOException ex = new IOException(
           "An unexpected error occurred querying the NodeStatus", e);
+      AUDIT.logReadFailure(buildAuditMessageForFailure(
+          SCMAction.QUERY_NODE, auditMap, ex));
+      throw ex;
     }
+    AUDIT.logReadSuccess(buildAuditMessageForSuccess(
+        SCMAction.QUERY_NODE, auditMap));
     return result;
   }
 
   @Override
   public List<DatanodeAdminError> decommissionNodes(List<String> nodes, 
boolean force)
       throws IOException {
+    final Map<String, String> auditMap = Maps.newHashMap();
+    auditMap.put("nodes", String.valueOf(nodes));
+    auditMap.put("force", String.valueOf(force));
+
     try {
       getScm().checkAdminAccess(getRemoteUser(), false);
-      return scm.getScmDecommissionManager().decommissionNodes(nodes, force);
+      List<DatanodeAdminError> result =  
scm.getScmDecommissionManager().decommissionNodes(nodes, force);
+      AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
+          SCMAction.DECOMMISSION_NODES, auditMap));
+      return result;
     } catch (Exception ex) {
-      LOG.error("Failed to decommission nodes", ex);
+      AUDIT.logWriteFailure(buildAuditMessageForFailure(
+          SCMAction.DECOMMISSION_NODES, auditMap, ex));
       throw ex;
     }
   }
 
   @Override
   public List<DatanodeAdminError> recommissionNodes(List<String> nodes)
       throws IOException {
+    final Map<String, String> auditMap = Maps.newHashMap();
+    auditMap.put("nodes", String.valueOf(nodes));
     try {
       getScm().checkAdminAccess(getRemoteUser(), false);
-      return scm.getScmDecommissionManager().recommissionNodes(nodes);
+      List<DatanodeAdminError> result = 
scm.getScmDecommissionManager().recommissionNodes(nodes);
+      AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
+          SCMAction.DECOMMISSION_NODES, auditMap));
+      return result;
     } catch (Exception ex) {

Review Comment:
   This excerpt is unlike the one immediately before it.  GitHub may not 
display your comments in the order you intended.  So comments like "same as 
above" or "ditto" are hard to understand for the author.
   
   I think it's better to mention in a single comment that there are similar 
issues, with specific code references if there aren't too many and you have the 
time.



-- 
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-unsubscr...@ozone.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org
For additional commands, e-mail: issues-h...@ozone.apache.org

Reply via email to