Uploaded image for project: 'Apache Knox'
  1. Apache Knox
  2. KNOX-2756

NPE occurred while getting service discovery types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 2.0.0
    • 2.0.0
    • Server
    • None

    Description

      With KNOX-2742 we added the ability to retry automated service discovery using Cloudera Manager in case od certain connection errors.

      To be able to do that, the newly introduced retry parameters are configured during the init phase of when an instance of ClouderaManagerServiceDiscovery is created.

      This implementation takes the gatewayConfig object granted, which is always there when Knox actually uses the service discovery in the descriptors.

      However, there is another use case if this class added by KNOX-1914: on our Admin UI, when creating/updating descriptors, there is a call to fetch the available service discoveries to be able to display in a dropdown list. This call creates the ClouderaManagerServiceDiscovery instance in a way that the given gatewayConfig attribute is null -> a NPE exception is thrown:

      $ curl -iku admin:admin-password https://localhost:8443/gateway/admin/api/v1/servicediscoveries
      HTTP/1.1 500 Server Error
      Set-Cookie: KNOXSESSIONID=node010wlhopeuv6je1hcl8qc480wq50.node0; Path=/gateway/admin; Secure; HttpOnly
      Set-Cookie: rememberMe=deleteMe; Path=/gateway/admin; Max-Age=0; Expires=Thu, 02-Jun-2022 05:02:44 GMT; SameSite=lax
      Cache-Control: must-revalidate,no-cache,no-store
      Content-Type: text/html;charset=iso-8859-1
      Content-Length: 434
      Connection: close
      
      
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
      <title>Error 500 Request failed.</title>
      </head>
      <body><h2>HTTP ERROR 500 Request failed.</h2>
      <table>
      <tr><th>URI:</th><td>/gateway/admin/api/v1/servicediscoveries</td></tr>
      <tr><th>STATUS:</th><td>500</td></tr>
      <tr><th>MESSAGE:</th><td>Request failed.</td></tr>
      <tr><th>SERVLET:</th><td>admin-knox-gateway-servlet</td></tr>
      </table>
      
      
      </body>
      </html> 

      In gateway.log:

      2022-06-03 07:02:45,686 c4d26549-91c8-41d1-a44e-1c1dead70d30 ERROR knox.gateway (GatewayFilter.java:doFilter(189)) - Gateway processing failed: javax.servlet.ServletException: org.apache.shiro.subject.ExecutionException: java.security.PrivilegedActionException: javax.servlet.ServletException: java.lang.NullPointerException
      javax.servlet.ServletException: org.apache.shiro.subject.ExecutionException: java.security.PrivilegedActionException: javax.servlet.ServletException: java.lang.NullPointerException
      	at org.apache.shiro.web.servlet.AdviceFilter.cleanup(AdviceFilter.java:196) ~[shiro-web-1.8.0.jar:1.8.0]
      ...
      Caused by: java.lang.NullPointerException
      	at org.apache.knox.gateway.topology.discovery.cm.ClouderaManagerServiceDiscovery.configureRetryParams(ClouderaManagerServiceDiscovery.java:120) ~[gateway-discovery-cm-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.apache.knox.gateway.topology.discovery.cm.ClouderaManagerServiceDiscovery.<init>(ClouderaManagerServiceDiscovery.java:116) ~[gateway-discovery-cm-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.apache.knox.gateway.topology.discovery.cm.ClouderaManagerServiceDiscovery.<init>(ClouderaManagerServiceDiscovery.java:100) ~[gateway-discovery-cm-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.apache.knox.gateway.topology.discovery.cm.ClouderaManagerServiceDiscoveryType.newInstance(ClouderaManagerServiceDiscoveryType.java:35) ~[gateway-discovery-cm-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
      	at org.apache.knox.gateway.topology.discovery.ServiceDiscoveryFactory.lambda$0(ServiceDiscoveryFactory.java:54) ~[gateway-spi-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT] 

      Attachments

        Issue Links

          Activity

            People

              smolnar Sandor Molnar
              smolnar Sandor Molnar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m