sumitagrawl commented on code in PR #8858: URL: https://github.com/apache/ozone/pull/8858#discussion_r2239013546
########## hadoop-ozone/dist/src/shell/conf/bgdeletion-audit-log4j2.properties: ########## @@ -0,0 +1,100 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# <p> +# http://www.apache.org/licenses/LICENSE-2.0 +# <p> +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS,WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +name=PropertiesConfig + +# Checks for config change periodically and reloads +monitorInterval=30 + +filter=read,write +# filter.read.onMatch=DENY avoids logging all READ events +# filter.read.onMatch=ACCEPT permits logging all READ events +# The above two settings ignore the log levels in configuration +# filter.read.onMatch=NEUTRAL permits logging of only those READ events +# which are attempted at log level equal or greater than log level specified +# in the configuration +filter.read.type=MarkerFilter +filter.read.marker=READ +filter.read.onMatch=NEUTRAL +filter.read.onMismatch=NEUTRAL + +# filter.write.onMatch=DENY avoids logging all WRITE events +# filter.write.onMatch=ACCEPT permits logging all WRITE events +# The above two settings ignore the log levels in configuration +# filter.write.onMatch=NEUTRAL permits logging of only those WRITE events +# which are attempted at log level equal or greater than log level specified +# in the configuration +filter.write.type=MarkerFilter +filter.write.marker=WRITE +filter.write.onMatch=NEUTRAL +filter.write.onMismatch=NEUTRAL + +# Log Levels are organized from most specific to least: +# OFF (most specific, no logging) +# FATAL (most specific, little data) +# ERROR +# WARN +# INFO +# DEBUG +# TRACE (least specific, a lot of data) +# ALL (least specific, all data) + +# Uncomment following section to enable logging to console appender also +#appenders=console, rolling +#appender.console.type=Console +#appender.console.name=STDOUT +#appender.console.layout.type=PatternLayout +#appender.console.layout.pattern=%d{DEFAULT} | %-5level | %c{1} | %msg | %throwable{3} %n + +# Comment this line when using both console and rolling appenders +appenders=bgdelrolling + +# Rolling File Appender with size & time thresholds. +# Rolling is triggered when either threshold is breached. +# The rolled over file is compressed by default +# Time interval is specified in seconds 86400s=1 day +# Audit files under the base directory that are 30 days old +# or older are deleted at rollover time +appender.bgdelrolling.type=RollingFile +appender.bgdelrolling.name=BgDeletionRollingFile +appender.bgdelrolling.fileName =${sys:hadoop.log.dir}/bgdeletion-audit-${hostName}.log Review Comment: its should be named as system-audit-** , not bgdeletion, as this is one of specific log it will have ########## hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyPurgeRequest.java: ########## @@ -119,6 +136,11 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, Execut return new OMKeyPurgeResponse(createErrorOMResponse(omResponse, e)); } + Map<String, String> auditParams = new HashMap<>(); + auditParams.put(AUDIT_PARAM_KEYS_DELETED, String.valueOf(numKeysDeleted)); + auditParams.put(AUDIT_PARAM_RENAMED_KEYS_PURGED, String.valueOf(renamedKeysToBePurged.size())); + AUDIT.logWriteSuccess(buildAuditMessageForBGD(BackgroundDeletionAction.KEY_DELETION, Review Comment: Need use OMSystemAction only, no need define another action. ########## hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/DeleteBlocksCommandHandler.java: ########## @@ -543,7 +563,13 @@ private void markBlocksForDeletionTransaction( updateMetaData(containerData, delTX, newDeletionBlocks, containerDB, batch); containerDB.getStore().getBatchHandler().commitBatchOperation(batch); + AUDIT.logWriteSuccess(buildAuditMessageForSuccess( + BackgroundDeletionAction.BLOCK_DELETION, auditParams)); } + } catch (IOException e) { + AUDIT.logWriteFailure(buildAuditMessageForFailure( + BackgroundDeletionAction.BLOCK_DELETION, auditParams, e)); Review Comment: DNSystemAction to be used instead of BackgroundDeletionAction ########## hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMBlockProtocolServer.java: ########## @@ -318,12 +322,17 @@ public List<DeleteBlockGroupResult> deleteKeyBlocks( results.add(new DeleteBlockGroupResult(bg.getGroupID(), blockResult)); } auditMap.put("KeyBlockToDelete", keyBlocksInfoList.toString()); + auditMap.put("NumOfKeyBlocksToDelete", String.valueOf(keyBlocksInfoList.size())); if (e == null) { AUDIT.logWriteSuccess( buildAuditMessageForSuccess(SCMAction.DELETE_KEY_BLOCK, auditMap)); + BG_DELETION_AUDIT.logWriteSuccess( Review Comment: We do not need another audit log if above are there. this is to log external request. May be can check if comming or not. ########## hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/snapshot/OMSnapshotPurgeRequest.java: ########## @@ -125,11 +135,23 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, Execut omSnapshotIntMetrics.incNumSnapshotPurges(); LOG.info("Successfully executed snapshotPurgeRequest: {{}} along with updating snapshots:{}.", snapshotPurgeRequest, updatedSnapshotInfos); + + Map<String, String> auditParams = new HashMap<>(); Review Comment: a common method to prepare audit map, with both failure/success, as failure will have additional parameter of failure information. follow similar mechansim as done for other audit. ########## hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyPurgeRequest.java: ########## @@ -119,6 +136,11 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, Execut return new OMKeyPurgeResponse(createErrorOMResponse(omResponse, e)); } + Map<String, String> auditParams = new HashMap<>(); + auditParams.put(AUDIT_PARAM_KEYS_DELETED, String.valueOf(numKeysDeleted)); + auditParams.put(AUDIT_PARAM_RENAMED_KEYS_PURGED, String.valueOf(renamedKeysToBePurged.size())); + AUDIT.logWriteSuccess(buildAuditMessageForBGD(BackgroundDeletionAction.KEY_DELETION, Review Comment: eg: `auditMap.put("NewOmState", omState.name()); SYSTEMAUDIT.logWriteSuccess(buildAuditMessageForSuccess(OMSystemAction.STARTUP, auditMap));` ########## hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/audit/AuditLoggerType.java: ########## @@ -25,7 +25,8 @@ public enum AuditLoggerType { OMLOGGER("OMAudit"), SCMLOGGER("SCMAudit"), S3GLOGGER("S3GAudit"), - OMSYSTEMLOGGER("OMSystemAudit"); + OMSYSTEMLOGGER("OMSystemAudit"), + BGDELETIONLOGGER("BackgroundDeletionAudit"); Review Comment: use only OMSYSTEMLOGGER, no need define another BGDELETIONLOGGER -- 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]
