[NEUTRON-66] java.lang.NullPointerException at org.opendaylight.neutron.transcriber.NeutronSubnetInterface.fromMd Created: 09/Sep/15  Updated: 16/Oct/15  Resolved: 16/Oct/15

Status: Resolved
Project: neutron
Component/s: transcriber
Affects Version/s: master
Fix Version/s: None

Type: Bug
Reporter: Rijil Abraham Assignee: Ravindra Kenchappa
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Attachments: Text File karaf.log     File q-svc.log.2015-09-09-091950    
External issue ID: 4285

 Description   

While trying to display the subnet information, I hit on the following null pointer exception.

Here are the steps I did.
1)On a devstack (stable/kilo) setup installed ODL(beryllium)
2)Created a network with subnet
3)Deleted the subnet
4)Use api to display the subnet info.

GET controller/nb/v2/neutron/subnets

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 500 Server Error</title>
</head>
<body>
<h2>HTTP ERROR 500</h2>
<p>Problem accessing /controller/nb/v2/neutron/subnets. Reason:

<pre> Server Error</pre>
</p>
<h3>Caused by:</h3>
<pre>java.lang.NullPointerException
at org.opendaylight.neutron.transcriber.NeutronSubnetInterface.fromMd(NeutronSubnetInterface.java:163)
at org.opendaylight.neutron.transcriber.NeutronSubnetInterface.getAllSubnets(NeutronSubnetInterface.java:97)
at org.opendaylight.neutron.northbound.api.NeutronSubnetsNorthbound.listSubnets(NeutronSubnetsNorthbound.java:121)
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.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1496)
at org.eclipse.jetty.servlets.CrossOriginFilter.handle(CrossOriginFilter.java:247)
at org.eclipse.jetty.servlets.CrossOriginFilter.doFilter(CrossOriginFilter.java:210)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1467)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:69)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:240)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:75)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:745)
</pre>
<hr />
<i>
<small>Powered by Jetty://</small>
</i>

</body>
</html>



 Comments   
Comment by Rijil Abraham [ 09/Sep/15 ]

Attachment q-svc.log.2015-09-09-091950 has been added with description: q-svc log

Comment by Rijil Abraham [ 09/Sep/15 ]

Attachment karaf.log has been added with description: odl log

Comment by Rijil Abraham [ 14/Sep/15 ]

Exact steps to recreate the issue:

1)On a devstack (stable/kilo) setup installed ODL(beryllium)

2)Create a network using the POST API
POST http://105.0.1.210:8181/controller/nb/v2/neutron/networks
body - {"network": {"status": "ACTIVE", "subnets": [], "name": "tempest-test-network--35617655", "router:external": false, "tenant_id": "1d7ecd7c5a5b4f84afd5ddd735e0f6b6", "admin_state_up": true, "mtu": 0, "shared": false, "id": "9df465d6-e398-4a01-8f4d-071b5ac2f24d"}}

3)Create a subnet using POST API
POST http://105.0.1.210:8181/controller/nb/v2/neutron/subnets
body - {"subnet": {"name": "", "enable_dhcp": true, "network_id": "9df465d6-e398-4a01-8f4d-071b5ac2f24d", "tenant_id": "1d7ecd7c5a5b4f84afd5ddd735e0f6b6", "dns_nameservers": [], "gateway_ip": null, "ipv6_ra_mode": null, "allocation_pools": [

{"start": "2003::3", "end": "2003::4"}

], "host_routes": [], "ip_version": 6, "ipv6_address_mode": null, "cidr": "2003::/64", "id": "251598aa-bccf-4c1c-b429-655565b80f7e", "subnetpool_id": null}}

4)Delete the network using the DELETE API
DELETE http://105.0.1.210:8181/controller/nb/v2/neutron/networks/9df465d6-e398-4a01-8f4d-071b5ac2f24d

5)Now using the API display the subnet info
GET http://105.0.1.210:8181/controller/nb/v2/neutron/subnets

Comment by Ravindra Kenchappa [ 24/Sep/15 ]

When deleting the network in NeutronSubnetinterface.java it tries to access all the subnets belongs the network that being deleted. For some reason some of subnets do not have the gateway-ip and hence the NPE. When NPE check is added the issue is not seen and in the test-network.py tempest test 6 more tests case were passed. Now we have 6 failures related to UPDATE network testcase.

Comment by Isaku Yamahata [ 30/Sep/15 ]

https://git.opendaylight.org/gerrit/#/c/27619/

Can you please try the above patch?

Comment by Isaku Yamahata [ 30/Sep/15 ]

NOTE: looking at openstack neutron code, ipv6 ra mode and ipv6 address mode also can be null in addition to gateway ip.
So the uploaded patch includes null pointer check for all of three.

Comment by Ravindra Kenchappa [ 30/Sep/15 ]

I looked at the changes https://git.opendaylight.org/gerrit/#/c/27619/ and it should work, but the other 2 checks is not needed because there will not be NPE until the "subnet" is NULL.

if (subnet.getIpv6RaMode() != null) {
result.setIpV6RaMode(DHCPV6_MAP.get(subnet.getIpv6RaMode()));
}
if (subnet.getIpv6AddressMode() != null) { result.setIpV6AddressMode(DHCPV6_MAP.get(subnet.getIpv6AddressMode()));
}

In this test-case when the SUBNET is created the gateway-ip is set to NULL.

3)Create a subnet using POST API
POST http://105.0.1.210:8181/controller/nb/v2/neutron/subnets
body - {"subnet": {"name": "", "enable_dhcp": true, "network_id": "9df465d6-e398-4a01-8f4d-071b5ac2f24d", "tenant_id": "1d7ecd7c5a5b4f84afd5ddd735e0f6b6", "dns_nameservers": [], "gateway_ip": null, "ipv6_ra_mode": null, "allocation_pools": [

{"start": "2003::3", "end": "2003::4"}

], "host_routes": [], "ip_version": 6, "ipv6_address_mode": null, "cidr": "2003::/64", "id": "251598aa-bccf-4c1c-b429-655565b80f7e", "subnetpool_id": null}}

And in fromMD() we tried to access the gateway_ip from the subnet object and tries get its vlaue, since gateway_ip is null we get NPE.

result.setGatewayIP(String.valueOf(subnet.getGatewayIp().getValue()));

We have encounter another issue and fixing that also and uploading that patch.

Generated at Wed Feb 07 20:25:28 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.