This is an automated email from the ASF dual-hosted git repository. madhan pushed a commit to branch ranger-2.7 in repository https://gitbox.apache.org/repos/asf/ranger.git
commit 21ae4575b855052bd5ac36355bd296796fd76c52 Author: Dineshkumar Yadav <[email protected]> AuthorDate: Tue Feb 4 11:33:50 2025 +0530 RANGER-5124 : The policy and tag active time are not in sync with the last update and policy download (cherry picked from commit 852d89486e739349dc2c958d46c2df19a3e3326a) --- .../main/java/org/apache/ranger/biz/AssetMgr.java | 71 +++++++++++++++------- 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java index 7ad19bc0c..f1eac0865 100644 --- a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java +++ b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java @@ -720,33 +720,58 @@ private void createOrUpdatePluginInfo(final RangerPluginInfo pluginInfo, int ent final Runnable commitWork; if (httpCode == HttpServletResponse.SC_NOT_MODIFIED) { - if (!pluginActivityAuditLogNotModified) { + RangerPluginInfo dbObj = null; + Long pluginActivationTime = null; + Long dbLastActivationTime = null; + + if (StringUtils.isNotBlank(pluginInfo.getServiceName())) { + XXPluginInfo xObj = rangerDaoManager.getXXPluginInfo().find(pluginInfo.getServiceName(), pluginInfo.getHostName(), pluginInfo.getAppType()); + if (xObj != null) { + dbObj = pluginInfoService.populateViewObject(xObj); + } + } + + // Create or update PluginInfo record after transaction is completed. If it is created in-line here + // then the TransactionManager will roll-back the changes because the HTTP return code is + // HttpServletResponse.SC_NOT_MODIFIED + + switch (entityType) { + case RangerPluginInfo.ENTITY_TYPE_POLICIES: + isTagVersionResetNeeded = rangerDaoManager.getXXService().findAssociatedTagService(pluginInfo.getServiceName()) == null; + + pluginActivationTime = pluginInfo.getPolicyActivationTime(); + dbLastActivationTime = dbObj != null ? dbObj.getPolicyActivationTime() : null; + break; + case RangerPluginInfo.ENTITY_TYPE_TAGS: + isTagVersionResetNeeded = false; + + pluginActivationTime = pluginInfo.getTagActivationTime(); + dbLastActivationTime = dbObj != null ? dbObj.getTagActivationTime() : null; + break; + case RangerPluginInfo.ENTITY_TYPE_ROLES: + isTagVersionResetNeeded = false; + + pluginActivationTime = pluginInfo.getRoleActivationTime(); + dbLastActivationTime = dbObj != null ? dbObj.getRoleActivationTime() : null; + break; + case RangerPluginInfo.ENTITY_TYPE_USERSTORE: + isTagVersionResetNeeded = false; + + pluginActivationTime = pluginInfo.getUserStoreActivationTime(); + dbLastActivationTime = dbObj != null ? dbObj.getUserStoreActivationTime() : null; + break; + default: + isTagVersionResetNeeded = false; + break; + } + + boolean isLastActivationTimeUpdateNeeded = pluginActivationTime != null && pluginActivationTime > 0 && (dbLastActivationTime == null || !dbLastActivationTime.equals(pluginActivationTime)); + + if (!pluginActivityAuditLogNotModified && !isLastActivationTimeUpdateNeeded) { logger.debug("Not logging HttpServletResponse. SC_NOT_MODIFIED. To enable, set configuration: {}=true", PROP_PLUGIN_ACTIVITY_AUDIT_NOT_MODIFIED); commitWork = null; } else { - // Create or update PluginInfo record after transaction is completed. If it is created in-line here - // then the TransactionManager will roll-back the changes because the HTTP return code is - // HttpServletResponse.SC_NOT_MODIFIED - - switch (entityType) { - case RangerPluginInfo.ENTITY_TYPE_POLICIES: - isTagVersionResetNeeded = rangerDaoManager.getXXService().findAssociatedTagService(pluginInfo.getServiceName()) == null; - break; - case RangerPluginInfo.ENTITY_TYPE_TAGS: - isTagVersionResetNeeded = false; - break; - case RangerPluginInfo.ENTITY_TYPE_ROLES: - isTagVersionResetNeeded = false; - break; - case RangerPluginInfo.ENTITY_TYPE_USERSTORE: - isTagVersionResetNeeded = false; - break; - default: - isTagVersionResetNeeded = false; - break; - } - commitWork = new Runnable() { @Override public void run() {
