Configure the policy list cache and policy update version check¶
Overview¶
For a service with a very large number of policies (200,000 or more), the policy list can take a long time to load or come back empty. With policy deltas off (the default), when any policy in the service changes, Ranger Admin reloads all policies of that service before it answers the next list request. At this size a full reload takes from tens of seconds to several minutes, and other list requests made during the reload wait 10 seconds (set by ranger.admin.policy.download.cache.max.waittime.for.update) and then return the previous list, or an empty list right after a restart.
Two Ranger Admin properties address this. They are part of Ranger Admin on both Trust3 AI Cloud and Self-Managed deployments, and both are off by default; with the defaults Ranger Admin behaves as before. Fresh installs and upgrades need no change: both stay off until you set them.
| Property | Default | Description |
|---|---|---|
ranger.admin.policy.list.async.refresh.min.load.time.ms | -1 (off) | When 0 or more, the policy list of a service returns the cached policies at once if the service's last full policy load took at least this many milliseconds, and reloads them in the background. Services that load faster, and a service with no cached policies yet, keep loading in the request. |
ranger.admin.policy.update.version.check.enabled | false | When true, a policy update returns HTTP 409 Conflict if the version in the request is not the policy's current version, so an update made from an older copy of the policy cannot overwrite newer changes. |
Both properties apply to every service in Ranger Admin and take effect after Ranger Admin restarts.
Policy list cache¶
With the cache on, a list request no longer waits for the reload. The trade-off is that the list can lag behind the latest changes by the wait for one of the 4 shared background refresh threads plus one full reload of the service. Only opening a single policy (GET /service/plugins/policies/{id}) always reads the current policy; other policy reads, such as the policy list by service name, can also return the previous policies while a reload is running, as before.
Only the policy list by service ID (GET /service/plugins/policies/service/{id}) uses the cache. This is the list in the Resource Policies page of the Trust3 AI Portal and the policy list in the Ranger Admin UI. Plugin policy downloads and other APIs are unchanged.
Policy update version check¶
With the version check on, a policy update that carries a version must carry the policy's current version, or it gets 409 Conflict and the client must read the policy again before it saves. This includes:
- Reverting a policy to an earlier version in the Ranger Admin UI.
- Updating a policy with a body exported earlier.
| Request | Version checked |
|---|---|
PUT /service/plugins/policies/{id} with a version | Yes |
Public v2 API PUT /service/public/v2/api/policy/{id} and PUT /service/public/v2/api/service/{servicename}/policy/{policyname}, with a version | Yes |
Any of the above without a version | No |
Public v1 API PUT /service/public/api/policy/{id} (the version is always taken from the database) | No |
| Legacy asset API | No |
Unified UI PUT /service/plugins/policies/unified/{id} | No |
Import and apply (updateIfExists) | No |
Owners of API clients that update policies should send the version they read with the policy, and handle 409 Conflict by reading the policy by ID again and retrying.
In the Trust3 AI Portal, an approved access request that hits 409 Conflict is marked Provisioning Failed with the error from Ranger Admin, and the user tries the request again. No grant is lost silently. The Portal reads the policy from the cached list before it saves a grant, so with both properties on, an approval on a policy that changed since the last cached load fails this way, and so does a retry, until the next background reload finishes. Retry such approvals after the reload.
Turn on the version check before the policy list cache
With the cache on, the policy list can return an older copy of a policy. A client that edits that copy and saves it without the version check can overwrite newer changes, such as grants made by another approved access request. Roll out in this order:
- Make sure API clients that update policies from the list send the
versionthey read and handle409 Conflictby reading the policy again and retrying. - Turn on
ranger.admin.policy.update.version.check.enabledand restart Ranger Admin. - Set
ranger.admin.policy.list.async.refresh.min.load.time.msand restart Ranger Admin.
You can set both properties in one update only when step 1 is already done for every client.
Configure the properties¶
These steps are for Self-Managed deployments. On Trust3 AI Cloud both properties stay off, so Ranger Admin there is not affected.
- SSH into the instance where Privacera Manager is installed.
- Navigate to the
privacera-managerdirectory:Bash - Create the custom properties folder if it does not exist, and open the Ranger Admin custom site file:
- Add the version check property: Add only
XML <property>blocks to this file, without a<configuration>element; Privacera Manager adds them to Ranger Admin'sranger-privacera-site.xml. - Update your Privacera Manager platform instance: Step 1 - Setup which generates the helm charts. This step usually takes few minutes. Step 2 - Apply the Privacera Manager helm charts. Step 3 - (Optional) Post-installation step which generates Plugin tar ball, updates Route 53 DNS and so on. This step is not required if you are updating only connector properties.
| XML | |
|---|---|
| Bash | |
|---|---|
ranger.admin.policy.list.async.refresh.min.load.time.ms=5000, ranger.admin.policy.update.version.check.enabled=true. If it shows -1 and false, the properties were not applied. To turn the features off, remove the properties and update again. If you remove them one at a time, remove the policy list cache property first; do not leave the cache on with the version check off.
Choose a threshold¶
Ranger Admin records how long the last full policy load of each service took. With Ranger metrics enabled, compare the threshold with the ranger_admin_policystore_cache_db_fullloadtime_ms gauge. A threshold of 5000 leaves services with fewer policies on the usual path and moves only the slow ones to the cache.
Metrics¶
Ranger Admin exports these metrics in Prometheus format at /service/metrics/prometheus.
| Metric | Type | Description |
|---|---|---|
ranger_admin_policystore_cache_db_fullloadtime_ms{tenantId,servicename} | Gauge | Duration of the last full policy load of the service, in milliseconds. |
ranger_admin_policystore_cache_list_refresh_total{tenantId,servicename,result} | Counter | Background reloads of the policy list cache. result is success, failure, lock_timeout or rejected. |
ranger_admin_policystore_cache_list_refresh_queue | Gauge | Background reloads waiting to run. |
ranger_admin_policy_update_conflict_total{tenantId,reason} | Counter | Policy updates rejected with 409 Conflict. reason is stale_version (the request's version was old) or concurrent_write (another update saved the policy at the same time). |
Limitations¶
- If background reloads keep failing, the list stays at the last cached policies. Each failure is counted in
ranger_admin_policystore_cache_list_refresh_totalwithresult="failure", and the next reload of that service waits 30 seconds, doubling up to 10 minutes, until a load of the service succeeds. A reload that cannot be started (result="rejected") is only counted; the next list request tries again. - Ranger Admin logs the values of both properties on the first policy request after it starts, not when it starts, and logs a warning then when the policy list cache is on but the version check is off.
- Right after Ranger Admin starts, the first list request for a service loads its policies in the request, as before.
- With the cache on, security zone administrators and delegated administrators can see a policy that was deleted, moved to another zone, or whose resources moved out of their scope, as it was at the last cached load, until the next background reload succeeds. While reloads keep failing, this lasts as long as the failure backoff above.
- Prev topic: Advanced Configurations