Skip to content
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

HDDS-12175. Audit logs in SCM shouldn't print delete txns #7805

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,29 @@ 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: ").append(cmd.getCommandType());
auditMap.append(" deleteTransactionsCount:");
auditMap.append(cmd.getDeleteBlocksCommandProto().getDeletedBlocksTransactionsList().size());
} else {
Tejaskriya marked this conversation as resolved.
Show resolved Hide resolved
auditMap.append(cmd);
}
auditMap.append(" , ");
Tejaskriya marked this conversation as resolved.
Show resolved Hide resolved
}
int len = auditMap.toString().length();
Tejaskriya marked this conversation as resolved.
Show resolved Hide resolved
if (len > 3) {
auditMap.deleteCharAt(len - 1);
auditMap.deleteCharAt(len - 2);
auditMap.deleteCharAt(len - 3);
}
Tejaskriya marked this conversation as resolved.
Show resolved Hide resolved
auditMap.append(']');
return auditMap.toString();
}

@Override
public SCMHeartbeatResponseProto sendHeartbeat(
SCMHeartbeatRequestProto heartbeat) throws IOException, TimeoutException {
Expand All @@ -291,7 +314,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