Sanket-Shelar commented on code in PR #1103:
URL: https://github.com/apache/ranger/pull/1103#discussion_r3821610645
##########
ugsync/src/main/java/org/apache/ranger/unixusersync/process/PolicyMgrUserGroupBuilder.java:
##########
@@ -1375,28 +1393,41 @@ private void getUserGroupAuditInfo(UgsyncAuditInfo
userInfo) {
checkStatus();
- String response = null;
- Response clientRes = null;
+ String response = null;
if (isRangerCookieEnabled) {
response = cookieBasedUploadEntity(userInfo, PM_AUDIT_INFO_URI);
} else {
try {
- clientRes = ldapUgSyncClient.post(PM_AUDIT_INFO_URI, null,
userInfo);
+ Response clientRes = ldapUgSyncClient.post(PM_AUDIT_INFO_URI,
null, userInfo);
if (clientRes != null) {
response = clientRes.readEntity(String.class);
}
} catch (Throwable t) {
LOG.error("Failed to get response, Error is : ", t);
+
metricCacheUtil.incrementMetric(MetricCacheUtil.MetricType.API,
MetricCacheUtil.AUDIT_COUNT_FAIL, 1L);
+ LOG.debug("<==
PolicyMgrUserGroupBuilder.getUserGroupAuditInfo()");
+ return;
}
}
LOG.debug("REST response from {} : {}", PM_AUDIT_INFO_URI, response);
- JsonUtils.jsonToObject(response, UgsyncAuditInfo.class);
+ if (StringUtils.isNotEmpty(response)) {
+ try {
+ JsonUtils.jsonToObject(response, UgsyncAuditInfo.class);
+
metricCacheUtil.incrementMetric(MetricCacheUtil.MetricType.API,
MetricCacheUtil.AUDIT_COUNT_SUCCESS, 1L);
+ LOG.debug("AuditInfo Creation successful ");
+ } catch (Exception e) {
+ LOG.error("Failed to parse audit info response", e);
+
metricCacheUtil.incrementMetric(MetricCacheUtil.MetricType.API,
MetricCacheUtil.AUDIT_COUNT_FAIL, 1L);
+ }
+ } else {
+ LOG.error("Failed to post audit info - empty response from {}",
PM_AUDIT_INFO_URI);
+ metricCacheUtil.incrementMetric(MetricCacheUtil.MetricType.API,
MetricCacheUtil.AUDIT_COUNT_FAIL, 1L);
Review Comment:
Updated the empty-response branch to increment fail only when
!isRangerCookieEnabled, avoiding double counting.
--
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]