Skip to content

Commit

Permalink
HDDS-12175. Audit logs in SCM shouldn't print delete txns
Browse files Browse the repository at this point in the history
  • Loading branch information
tejaskriya committed Feb 4, 2025
1 parent cfe56de commit ab716c3
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,22 @@ public static SCMRegisteredResponseProto getRegisteredResponse(
return cmd.getProtoBufMessage();
}

private String constructCommandAuditMap(List<SCMCommandProto> cmds) {
StringBuilder auditMap = new StringBuilder();
auditMap.append('[');
for (SCMCommandProto cmd : cmds) {
if (cmd.getCommandType().equals(deleteBlocksCommand)) {
auditMap.append("commandType:" + cmd.getCommandType());
auditMap.append(" No. of deleteTransactions:");
auditMap.append(cmd.getDeleteBlocksCommandProto().getDeletedBlocksTransactionsList().size());
} else {
auditMap.append(cmd);
}
}
auditMap.append(']');
return auditMap.toString();
}

@Override
public SCMHeartbeatResponseProto sendHeartbeat(
SCMHeartbeatRequestProto heartbeat) throws IOException, TimeoutException {
Expand All @@ -291,7 +307,7 @@ public SCMHeartbeatResponseProto sendHeartbeat(
boolean auditSuccess = true;
Map<String, String> auditMap = Maps.newHashMap();
auditMap.put("datanodeUUID", heartbeat.getDatanodeDetails().getUuid());
auditMap.put("command", flatten(cmdResponses.toString()));
auditMap.put("command", flatten(constructCommandAuditMap(cmdResponses)));
term.ifPresent(t -> auditMap.put("term", String.valueOf(t)));
try {
SCMHeartbeatResponseProto.Builder builder =
Expand Down

0 comments on commit ab716c3

Please sign in to comment.