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

Not able to delete user or group if user/group has any policy defined.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.4.0
    • 0.5.2, 0.6.0
    • None
    • None

    Description

      If a user/group has some policy assigned (entry in x_perm_map table of database) then delete rest api is not able to delete user/group.

      It gives "404 not found" error that is not proper exception message.

      In log file catalina.out, below exception message is coming:
      [EL Warning]: 2014-12-26 16:24:02.643-UnitOfWork(382747336)-Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20131113-a7346c6): org.eclipse.persistence.exceptions.DatabaseException
      Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`ranger`.`x_perm_map`, CONSTRAINT `x_perm_map_FK_group_id` FOREIGN KEY (`group_id`) REFERENCES `x_group` (`id`))
      Error Code: 1451
      Call: DELETE FROM x_group WHERE (ID = ?)
      bind => [1 parameter bound]
      Query: DeleteObjectQuery(XXGroup={XXDBBase={createTime=

      Unknown macro: {Thu Dec 25 12}

      updateTime=

      Unknown macro: {Thu Dec 25 12}

      addedByUserId=

      Unknown macro: {1}

      updatedByUserId=

      }name=

      Unknown macro: {Group5}

      description={} status=

      Unknown macro: {0}

      groupType=

      credStoreId=

      Unknown macro: {null}

      groupSrc=

      Unknown macro: {0}

      })
      Dec 26, 2014 4:24:02 PM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
      SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
      javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20131113-a7346c6): org.eclipse.persistence.exceptions.DatabaseException
      Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`ranger`.`x_perm_map`, CONSTRAINT `x_perm_map_FK_group_id` FOREIGN KEY (`group_id`) REFERENCES `x_group` (`id`))
      Error Code: 1451
      Call: DELETE FROM x_group WHERE (ID = ?)
      bind => [1 parameter bound]
      Query: DeleteObjectQuery(XXGroup={XXDBBase={createTime=

      Unknown macro: {Thu Dec 25 12}

      updateTime=

      Unknown macro: {Thu Dec 25 12}

      addedByUserId=

      Unknown macro: {1}

      updatedByUserId=

      }name=

      description={} status=

      Unknown macro: {0}

      groupType=

      credStoreId=

      Unknown macro: {null}

      groupSrc=

      Unknown macro: {0}

      })
      at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:868)
      at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
      at com.sun.proxy.$Proxy20.flush(Unknown Source)
      at org.apache.ranger.common.db.BaseDao.remove(BaseDao.java:106)
      at org.apache.ranger.common.db.BaseDao.remove(BaseDao.java:97)
      at org.apache.ranger.biz.XUserMgr.deleteXGroup(XUserMgr.java:77)
      at org.apache.ranger.rest.XUserREST.deleteXGroupByGroupName(XUserREST.java:545)
      at org.apache.ranger.rest.XUserREST$$FastClassByCGLIB$$b2a65360.invoke(<generated>)
      at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
      at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
      at org.apache.ranger.rest.XUserREST$$EnhancerByCGLIB$$246afd5.deleteXGroupByGroupName(<generated>)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$VoidOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:151)
      at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:70)
      at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:279)
      at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)
      at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:86)
      at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:136)
      at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:74)
      at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1357)
      at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1289)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1239)
      at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1229)
      at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:420)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:497)
      at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:684)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186)
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:744)
      Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20131113-a7346c6): org.eclipse.persistence.exceptions.DatabaseException
      Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`ranger`.`x_perm_map`, CONSTRAINT `x_perm_map_FK_group_id` FOREIGN KEY (`group_id`) REFERENCES `x_group` (`id`))

      Rest apis used for delete are:

      DELETE http://<ip>:6080/service/xusers/users/userName/<userName>
      DELETE http://<ip>:6080/service/xusers/groups/groupName/<groupName>
      DELETE http://<ip>:6080/service/xusers/groups/<id>
      DELETE http://<ip>:6080/service/xusers/users/<id>

      If user/group don't have any policy assigned then user/group get successfully deleted and get invisible from UI. Also mapping of user-group get deleted from database(x_group_users table).

      Attachments

        1. RANGER-204-0.5.patch
          50 kB
          Gautam Borad
        2. RANGER-204-master.patch
          53 kB
          Gautam Borad

        Issue Links

          Activity

            People

              gautamborad Gautam Borad
              hanish.bansal.agarwal Hanish Bansal
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: