Uploaded image for project: 'Ranger'
  1. Ranger
  2. RANGER-1025

Policy search REST API implemented in public api V1 is not returning results as expected

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.6.0
    • 0.6.0
    • Ranger
    • None

    Description

      If pageSize is big enough to include the policies we are searching for we get the results we expect.
      curl -u admin:admin -p -k -X GET "http://localhost:6080/service/public/api/policy?repositoryName=Sandbox_hadoop&resourceName=test&pageSize=2”

      { "startIndex": 0, "pageSize": 1, "totalCount": 1, "resultSize": 1, "queryTimeMS": 1465234633007, "vXPolicies": [ { "id": 7, "createDate": "2016-03-14T14:49:35Z", "updateDate": "2016-06-06T16:14:52Z", "owner": "Admin", "updatedBy": "Admin", "policyName": "HDFS Global Allow", "resourceName": "/,/*,test", "description": "This policy gives global permission for all users. Disable this to test Apache Ranger", "repositoryName": "Sandbox_hadoop", "repositoryType": "hdfs", "permMapList": [ { "userList": [], "groupList": [ "public" ], "permList": [ "Read", "Write", "Execute", "Admin" ] }

      ],
      "isEnabled": true,
      "isRecursive": true,
      "isAuditEnabled": true,
      "version": "7",
      "replacePerm": false
      }
      ]
      }
      Not returning a policy as expected. It seems as if the filtering is happening after retrieving the first n policies where n is the pageSize.
      curl -u admin:admin -p -k -X GET "http://localhost:6080/service/public/api/policy?repositoryName=Sandbox_hadoop&resourceName=test&pageSize=1”

      {"startIndex":0,"pageSize":0,"totalCount":0,"resultSize":0,"queryTimeMS":1465234722982,"vXPolicies":[]}

      This shows page size of 1 is clipping the results:
      You can see pageSize=1 returns the first policy ordered by id
      curl -u admin:admin -p -k -X GET "http://localhost:6080/service/public/api/policy?repositoryName=Sandbox_hadoop&pageSize=1”

      { "startIndex": 0, "pageSize": 1, "totalCount": 1, "resultSize": 1, "queryTimeMS": 1465234853741, "vXPolicies": [ { "id": 5, "createDate": "2016-03-14T14:45:45Z", "updateDate": "2016-03-14T14:45:46Z", "owner": "ranger_admin", "updatedBy": "ranger_admin", "policyName": "Sandbox_hadoop-1-20160314144545", "resourceName": "/*", "description": "Default Policy for Service: Sandbox_hadoop", "repositoryName": "Sandbox_hadoop", "repositoryType": "hdfs", "permMapList": [ { "userList": [ "ambari-qa" ], "groupList": [], "permList": [ "Read", "Write", "Execute", "Admin" ] }

      ],
      "isEnabled": true,
      "isRecursive": true,
      "isAuditEnabled": true,
      "version": "2",
      "replacePerm": false
      }
      ]
      }
      And this shows with default page size, all results are returned:
      All the HDFS policies (I believe default pageSize is 200):
      curl -u admin:admin -p -k -X GET "http://localhost:6080/service/public/api/policy?repositoryName=Sandbox_hadoop”

      { "startIndex": 0, "pageSize": 2, "totalCount": 2, "resultSize": 2, "queryTimeMS": 1465234768768, "vXPolicies": [ { "id": 5, "createDate": "2016-03-14T14:45:45Z", "updateDate": "2016-03-14T14:45:46Z", "owner": "ranger_admin", "updatedBy": "ranger_admin", "policyName": "Sandbox_hadoop-1-20160314144545", "resourceName": "/*", "description": "Default Policy for Service: Sandbox_hadoop", "repositoryName": "Sandbox_hadoop", "repositoryType": "hdfs", "permMapList": [ { "userList": [ "ambari-qa" ], "groupList": [], "permList": [ "Read", "Write", "Execute", "Admin" ] }

      ],
      "isEnabled": true,
      "isRecursive": true,
      "isAuditEnabled": true,
      "version": "2",
      "replacePerm": false
      },

      { "id": 7, "createDate": "2016-03-14T14:49:35Z", "updateDate": "2016-06-06T16:14:52Z", "owner": "Admin", "updatedBy": "Admin", "policyName": "HDFS Global Allow", "resourceName": "/,/*,test", "description": "This policy gives global permission for all users. Disable this to test Apache Ranger", "repositoryName": "Sandbox_hadoop", "repositoryType": "hdfs", "permMapList": [ { "userList": [], "groupList": [ "public" ], "permList": [ "Read", "Write", "Execute", "Admin" ] }

      ],
      "isEnabled": true,
      "isRecursive": true,
      "isAuditEnabled": true,
      "version": "7",
      "replacePerm": false
      }
      ]
      }

      Attachments

        1. RANGER-1025-1.patch
          10 kB
          Pradeep Agrawal

        Issue Links

          Activity

            People

              pradeep Pradeep Agrawal
              pradeep Pradeep Agrawal
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: