HDFS-17469. Audit log for reportBadBlocks RPC (#6731)
This commit is contained in:
parent
782c501441
commit
23286b0632
@ -993,6 +993,7 @@ public boolean complete(String src, String clientName,
|
|||||||
public void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
|
public void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
|
||||||
checkNNStartup();
|
checkNNStartup();
|
||||||
namesystem.reportBadBlocks(blocks);
|
namesystem.reportBadBlocks(blocks);
|
||||||
|
namesystem.logAuditEvent(true, "reportBadBlocks", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // ClientProtocol
|
@Override // ClientProtocol
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
import org.apache.hadoop.hdfs.protocol.CachePoolEntry;
|
import org.apache.hadoop.hdfs.protocol.CachePoolEntry;
|
||||||
import org.apache.hadoop.hdfs.protocol.CachePoolInfo;
|
import org.apache.hadoop.hdfs.protocol.CachePoolInfo;
|
||||||
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
||||||
|
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
||||||
import org.apache.hadoop.hdfs.server.protocol.DatanodeStorageReport;
|
import org.apache.hadoop.hdfs.server.protocol.DatanodeStorageReport;
|
||||||
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
|
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
|
||||||
import org.apache.hadoop.ipc.RPC;
|
import org.apache.hadoop.ipc.RPC;
|
||||||
@ -1218,6 +1219,25 @@ public void testDeleteRoot() throws Exception {
|
|||||||
verifyAuditLogs(aceDeletePattern);
|
verifyAuditLogs(aceDeletePattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReportBadBlocks() throws IOException {
|
||||||
|
String auditLogString =
|
||||||
|
".*allowed=true.*cmd=reportBadBlocks.*";
|
||||||
|
FSNamesystem fsNamesystem = spy(cluster.getNamesystem());
|
||||||
|
when(fsNamesystem.isExternalInvocation()).thenReturn(true);
|
||||||
|
Server.Call call = spy(new Server.Call(
|
||||||
|
1, 1, null, null, RPC.RpcKind.RPC_BUILTIN, new byte[] {1, 2, 3}));
|
||||||
|
when(call.getRemoteUser()).thenReturn(
|
||||||
|
UserGroupInformation.createRemoteUser(System.getProperty("user.name")));
|
||||||
|
Server.getCurCall().set(call);
|
||||||
|
try {
|
||||||
|
cluster.getNameNodeRpc().reportBadBlocks(new LocatedBlock[]{});
|
||||||
|
verifyAuditLogs(auditLogString);
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail(" The operation threw an exception" + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyAuditRestoreFailedStorageACE(
|
private void verifyAuditRestoreFailedStorageACE(
|
||||||
FSNamesystem fsNamesystem, String arg) throws IOException {
|
FSNamesystem fsNamesystem, String arg) throws IOException {
|
||||||
String operationName = fsNamesystem.getFailedStorageCommand(arg);
|
String operationName = fsNamesystem.getFailedStorageCommand(arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user