This is an automated email from the ASF dual-hosted git repository.

abhay pushed a commit to branch ranger-2.2
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/ranger-2.2 by this push:
     new 08fd8b1  RANGER-3034: Remove cached policies in plugin if the service 
is deleted in Ranger admin
08fd8b1 is described below

commit 08fd8b192a8aed00c977cb99e3fd06707ae10229
Author: Abhay Kulkarni <[email protected]>
AuthorDate: Mon Oct 12 07:06:28 2020 -0700

    RANGER-3034: Remove cached policies in plugin if the service is deleted in 
Ranger admin
---
 .../main/java/org/apache/ranger/plugin/util/PolicyRefresher.java | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git 
a/agents-common/src/main/java/org/apache/ranger/plugin/util/PolicyRefresher.java
 
b/agents-common/src/main/java/org/apache/ranger/plugin/util/PolicyRefresher.java
index ed05e87..dcba363 100644
--- 
a/agents-common/src/main/java/org/apache/ranger/plugin/util/PolicyRefresher.java
+++ 
b/agents-common/src/main/java/org/apache/ranger/plugin/util/PolicyRefresher.java
@@ -53,7 +53,6 @@ public class PolicyRefresher extends Thread {
        private final String                         cacheFileName;
        private final String                         cacheDir;
        private final Gson                           gson;
-       private final boolean                        
disableCacheIfServiceNotFound;
        private final BlockingQueue<DownloadTrigger> policyDownloadQueue = new 
LinkedBlockingQueue<>();
        private       Timer                          policyDownloadTimer;
        private       long                           lastKnownVersion    = -1L;
@@ -91,7 +90,6 @@ public class PolicyRefresher extends Thread {
                }
 
                this.gson                          = gson;
-               this.disableCacheIfServiceNotFound = 
pluginConfig.getBoolean(propertyPrefix + ".disable.cache.if.servicenotfound", 
true);
                this.rangerAdmin                   = 
RangerBasePlugin.createAdminClient(pluginConfig);
                this.rolesProvider                 = new 
RangerRolesProvider(getServiceType(), appId, getServiceName(), rangerAdmin,  
cacheDir, pluginConfig);
                this.pollingIntervalMs             = 
pluginConfig.getLong(propertyPrefix + ".policy.pollIntervalMs", 30 * 1000);
@@ -207,7 +205,7 @@ public class PolicyRefresher extends Thread {
                                loadRoles();
                                loadPolicy();
                        } catch(InterruptedException excp) {
-                               LOG.debug("PolicyRefresher(serviceName=" + 
serviceName + ").run(): interrupted! Exiting thread", excp);
+                               LOG.info("PolicyRefresher(serviceName=" + 
serviceName + ").run(): interrupted! Exiting thread", excp);
                                break;
                        } finally {
                                if (trigger != null) {
@@ -261,6 +259,7 @@ public class PolicyRefresher extends Thread {
                        if (svcPolicies != null) {
                                plugIn.setPolicies(svcPolicies);
                                policiesSetInPlugin = true;
+                               serviceDefSetInPlugin = false;
                                
setLastActivationTimeInMillis(System.currentTimeMillis());
                                lastKnownVersion = 
svcPolicies.getPolicyVersion() != null ? svcPolicies.getPolicyVersion() : -1L;
                        } else {
@@ -270,12 +269,12 @@ public class PolicyRefresher extends Thread {
                                }
                        }
                } catch (RangerServiceNotFoundException snfe) {
-                       if (disableCacheIfServiceNotFound) {
+                       if (!serviceDefSetInPlugin) {
                                disableCache();
                                plugIn.setPolicies(null);
+                               serviceDefSetInPlugin = true;
                                
setLastActivationTimeInMillis(System.currentTimeMillis());
                                lastKnownVersion = -1;
-                               serviceDefSetInPlugin = true;
                        }
                } catch (Exception excp) {
                        LOG.error("Encountered unexpected exception, 
ignoring..", excp);

Reply via email to