-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/74112/
-----------------------------------------------------------

(Updated Sept. 20, 2022, 4:24 a.m.)


Review request for ranger and Abhay Kulkarni.


Bugs: RANGER-3903
    https://issues.apache.org/jira/browse/RANGER-3903


Repository: ranger


Description (updated)
-------

After going through the below code snippets in the master branch 


while (iter.hasNext()) {
                            RangerPolicy policy = iter.next();
                            if (policyId.equals(policy.getId()) && (changeType 
== RangerPolicyDelta.CHANGE_TYPE_POLICY_DELETE || changeType == 
RangerPolicyDelta.CHANGE_TYPE_POLICY_UPDATE)) {
                                deletedPolicies.add(policy);
                                iter.remove();
                            }
                        }


switch(changeType) {
                            case RangerPolicyDelta.CHANGE_TYPE_POLICY_CREATE: {
                                if 
(CollectionUtils.isNotEmpty(deletedPolicies)) {
                                    LOG.warn("Unexpected: found existing policy 
for CHANGE_TYPE_POLICY_CREATE: " + Arrays.toString(deletedPolicies.toArray()));
                                }
                                break;
                            }
                            case RangerPolicyDelta.CHANGE_TYPE_POLICY_UPDATE: {
                                if (CollectionUtils.isEmpty(deletedPolicies) || 
deletedPolicies.size() > 1) {
                                    LOG.warn("Unexpected: found no policy or 
multiple policies for CHANGE_TYPE_POLICY_UPDATE: " + 
Arrays.toString(deletedPolicies.toArray()));
                                }
                                break;
                            }
                            case RangerPolicyDelta.CHANGE_TYPE_POLICY_DELETE: {
                                if (CollectionUtils.isEmpty(deletedPolicies) || 
deletedPolicies.size() > 1) {
                                    LOG.warn("Unexpected: found no policy or 
multiple policies for CHANGE_TYPE_POLICY_DELETE: " + 
Arrays.toString(deletedPolicies.toArray()));
                                }
                                break;
                            }
                            default:
                                break;
                        }


The below switch case statement is not needed 


case RangerPolicyDelta.CHANGE_TYPE_POLICY_CREATE: {
                                if 
(CollectionUtils.isNotEmpty(deletedPolicies)) {
                                    LOG.warn("Unexpected: found existing policy 
for CHANGE_TYPE_POLICY_CREATE: " + Arrays.toString(deletedPolicies.toArray()));
                                }
                                break;
                            }


As well as we no need to print the deletedPolicies as part of the log .Because 
we will upload the entire deletedPolicies into ELK stack when we index the log 
files

Or we need to the log under debug like 
 if (LOG.isDebugEnabled()) {
                                        LOG.debug("Unexpected: found no policy 
or multiple policies for CHANGE_TYPE_POLICY_UPDATE: " + 
Arrays.toString(deletedPolicies.toArray()));
                                    }


Diffs (updated)
-----

  
agents-common/src/main/java/org/apache/ranger/plugin/util/RangerPolicyDeltaUtil.java
 e9223fe69 


Diff: https://reviews.apache.org/r/74112/diff/2/

Changes: https://reviews.apache.org/r/74112/diff/1-2/


Testing
-------

Tested the below Rest API's to make sure everything works fine

1.  ServiceREST Rest API :GET /plugins/policies/download/{serviceName}

2.  ServiceREST Rest API :GET /plugins/secure/policies/download/{serviceName}


Thanks,

Ramachandran Krishnan

Reply via email to