-
Notifications
You must be signed in to change notification settings - Fork 518
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-11194. OM missing audit log for upgrade prepare, cancel and finalize #6958
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,12 @@ | |
import static org.apache.hadoop.ozone.OzoneConsts.LAYOUT_VERSION_KEY; | ||
import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type.FinalizeUpgrade; | ||
|
||
import java.util.HashMap; | ||
import org.apache.hadoop.hdds.protocol.proto.HddsProtos | ||
.UpgradeFinalizationStatus; | ||
import org.apache.hadoop.ozone.audit.AuditLogger; | ||
import org.apache.hadoop.ozone.audit.OMAction; | ||
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; | ||
import org.apache.ratis.server.protocol.TermIndex; | ||
import org.apache.hadoop.hdds.utils.db.cache.CacheKey; | ||
import org.apache.hadoop.hdds.utils.db.cache.CacheValue; | ||
|
@@ -58,10 +62,13 @@ public OMFinalizeUpgradeRequest(OMRequest omRequest) { | |
@Override | ||
public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIndex termIndex) { | ||
LOG.trace("Request: {}", getOmRequest()); | ||
AuditLogger auditLogger = ozoneManager.getAuditLogger(); | ||
OzoneManagerProtocolProtos.UserInfo userInfo = getOmRequest().getUserInfo(); | ||
OMResponse.Builder responseBuilder = | ||
OmResponseUtil.getOMResponseBuilder(getOmRequest()); | ||
responseBuilder.setCmdType(FinalizeUpgrade); | ||
OMClientResponse response = null; | ||
Exception exception = null; | ||
|
||
try { | ||
if (ozoneManager.getAclsEnabled()) { | ||
|
@@ -103,10 +110,13 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn | |
ozoneManager.getVersionManager().getMetadataLayoutVersion()); | ||
LOG.trace("Returning response: {}", response); | ||
} catch (IOException e) { | ||
exception = e; | ||
response = new OMFinalizeUpgradeResponse( | ||
createErrorOMResponse(responseBuilder, e), -1); | ||
} | ||
|
||
auditLog(auditLogger, buildAuditMessage(OMAction.UPGRADE_FINALIZE, | ||
new HashMap<>(), exception, userInfo)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TermIndex will be handled as part of "HDDS-10658. Add Object ID and Update ID to OM audit log messages" when this is merged. |
||
return response; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ | |
|
||
package org.apache.hadoop.ozone.om.request.upgrade; | ||
|
||
import java.util.HashMap; | ||
import org.apache.hadoop.ozone.audit.AuditLogger; | ||
import org.apache.hadoop.ozone.audit.OMAction; | ||
import org.apache.ratis.server.protocol.TermIndex; | ||
import org.apache.hadoop.ozone.om.OzoneManager; | ||
import org.apache.hadoop.ozone.om.exceptions.OMException; | ||
|
@@ -69,12 +72,15 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn | |
LOG.info("OM {} Received prepare request with log {}", ozoneManager.getOMNodeId(), termIndex); | ||
|
||
OMRequest omRequest = getOmRequest(); | ||
AuditLogger auditLogger = ozoneManager.getAuditLogger(); | ||
OzoneManagerProtocolProtos.UserInfo userInfo = omRequest.getUserInfo(); | ||
OzoneManagerProtocolProtos.PrepareRequestArgs args = | ||
omRequest.getPrepareRequest().getArgs(); | ||
OMResponse.Builder responseBuilder = | ||
OmResponseUtil.getOMResponseBuilder(omRequest); | ||
responseBuilder.setCmdType(Type.Prepare); | ||
OMClientResponse response = null; | ||
Exception exception = null; | ||
|
||
// Allow double buffer this many seconds to flush all transactions before | ||
// returning an error to the caller. | ||
|
@@ -123,13 +129,15 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn | |
"log index {}", ozoneManager.getOMNodeId(), transactionLogIndex, | ||
omResponse, omResponse.getTxnID()); | ||
} catch (OMException e) { | ||
exception = e; | ||
LOG.error("Prepare Request Apply failed in {}. ", | ||
ozoneManager.getOMNodeId(), e); | ||
response = new OMPrepareResponse( | ||
createErrorOMResponse(responseBuilder, e)); | ||
} catch (InterruptedException | IOException e) { | ||
// Set error code so that prepare failure does not cause the OM to | ||
// terminate. | ||
exception = e; | ||
LOG.error("Prepare Request Apply failed in {}. ", | ||
ozoneManager.getOMNodeId(), e); | ||
response = new OMPrepareResponse( | ||
|
@@ -149,6 +157,8 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, TermIn | |
} | ||
} | ||
|
||
auditLog(auditLogger, buildAuditMessage(OMAction.UPGRADE_PREPARE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TermIndex will be handled as part of "HDDS-10658. Add Object ID and Update ID to OM audit log messages" when this is merged implicitly. |
||
new HashMap<>(), exception, userInfo)); | ||
return response; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add
OMNodeId
andtermIndex
inauditMap
as an additional info for audit message ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TermIndex will be handled as part of "HDDS-10658. Add Object ID and Update ID to OM audit log messages" when this is merged.
OMNodeId is not required as audit-log is per node itself. There is no need for same.