chungen0126 commented on code in PR #11171:
URL: https://github.com/apache/ozone/pull/11171#discussion_r4085995025
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -3622,9 +3623,13 @@ public OmLifecycleConfiguration
getLifecycleConfiguration(String volumeName,
return metadataManager.getLifecycleConfiguration(
resolvedBucket.realVolume(), resolvedBucket.realBucket());
} catch (Exception ex) {
- auditSuccess = false;
- AUDIT.logReadFailure(buildAuditMessageForFailure(
- OMAction.GET_LIFECYCLE_CONFIGURATION, auditMap, ex));
+ // A bucket without a lifecycle configuration is an expected outcome, so
it
+ // is audited as a completed read rather than a failure.
+ if (!(ex instanceof OMException && ((OMException) ex).getResult() ==
LIFECYCLE_CONFIGURATION_NOT_FOUND)) {
+ auditSuccess = false;
+ AUDIT.logReadFailure(buildAuditMessageForFailure(
+ OMAction.GET_LIFECYCLE_CONFIGURATION, auditMap, ex));
+ }
Review Comment:
Can we just move all the logging from
`OmMetadataManagerImpl#getLifecycleConfiguration` over here? Catching it both
inside and outside feels a bit redundant. We can pull the debug log here as
well.
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmMetadataManager.java:
##########
@@ -168,6 +169,19 @@ public void setup() throws Exception {
omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration, null);
}
+ @Test
+ public void testGetMissingLifecycleConfigurationIsNotLoggedAsError() throws
Exception {
+ try (LogCapturer logCapturer =
LogCapturer.captureLogs(OmMetadataManagerImpl.class)) {
+ OMException ex = assertThrows(OMException.class, () ->
+ omMetadataManager.getLifecycleConfiguration("volume1", "bucket1"));
+
+ assertEquals(ResultCodes.LIFECYCLE_CONFIGURATION_NOT_FOUND,
ex.getResult());
+ // A bucket without a lifecycle configuration is an expected outcome, so
the
+ // catch-all must not report it with an error and a stack trace.
+ assertThat(logCapturer.getOutput()).doesNotContain("Exception while
getting lifecycle configuration");
+ }
+ }
+
Review Comment:
If we move the logging to OzoneManager, we won't need this test anymore.
--
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]