Bug 679472

Summary: NPE against a fresh deploy of candlepin onpremise followed by a register --autosubscribe
Product: [Community] Candlepin Reporter: John Sefler <jsefler>
Component: candlepinAssignee: Bryan Kearney <bkearney>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: high Docs Contact:
Priority: unspecified    
Version: 0.5CC: jharris, jmolet, spandey
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-30 20:43:44 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 568421    

Description John Sefler 2011-02-22 16:28:42 UTC
Description of problem:
After freshly deploying an onpremise candlepin from master branch and TESTDATA=1
I copied all the generated product certs to my client (running on a kvm guest) and ran subscription-manager register with autosubscribe.  Nothing gets autosubscribed and the catalina.out contains the following NullPointer stack trace:

Feb 22 11:08:13 [http-8443-2] ERROR org.fedoraproject.candlepin.exceptions.CandlepinExceptionMapper - Runtime exception:
org.jboss.resteasy.spi.ApplicationException: java.lang.NullPointerException
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:154)
	at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:248)
	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216)
	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:205)
	at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:489)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:466)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:120)
	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:200)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:48)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:43)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:216)
	at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:141)
	at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:93)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:63)
	at org.fedoraproject.candlepin.servlet.filter.logging.LoggingFilter.doFilter(LoggingFilter.java:60)
	at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:129)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:59)
	at com.wideplay.warp.persist.PersistenceFilter$3.run(PersistenceFilter.java:141)
	at com.wideplay.warp.persist.internal.Lifecycles.failEarlyAndLeaveNoOneBehind(Lifecycles.java:29)
	at com.wideplay.warp.persist.PersistenceFilter.doFilter(PersistenceFilter.java:155)
	at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:129)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:59)
	at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:122)
	at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:110)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.NullPointerException
	at org.fedoraproject.candlepin.policy.js.JsRules.getFlattenedAttributes(JsRules.java:122)
	at org.fedoraproject.candlepin.policy.js.entitlement.EntitlementRules.selectBestPools(EntitlementRules.java:217)
	at org.fedoraproject.candlepin.policy.EnforcerDispatcher.selectBestPools(EnforcerDispatcher.java:76)
	at org.fedoraproject.candlepin.controller.CandlepinPoolManager.entitleByProducts(CandlepinPoolManager.java:414)
	at org.fedoraproject.candlepin.controller.CandlepinPoolManager$$EnhancerByGuice$$277ffb5f.CGLIB$entitleByProducts$4(<generated>)
	at org.fedoraproject.candlepin.controller.CandlepinPoolManager$$EnhancerByGuice$$277ffb5f$$FastClassByGuice$$645f2826.invoke(<generated>)
	at com.google.inject.internal.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:64)
	at com.wideplay.warp.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:68)
	at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:64)
	at com.google.inject.InterceptorStackCallback.intercept(InterceptorStackCallback.java:44)
	at org.fedoraproject.candlepin.controller.CandlepinPoolManager$$EnhancerByGuice$$277ffb5f.entitleByProducts(<generated>)
	at org.fedoraproject.candlepin.resource.ConsumerResource.bindByProducts(ConsumerResource.java:446)
	at org.fedoraproject.candlepin.resource.ConsumerResource.bind(ConsumerResource.java:623)
	at org.fedoraproject.candlepin.resource.ConsumerResource$$EnhancerByGuice$$8e2e0224.CGLIB$bind$2(<generated>)
	at org.fedoraproject.candlepin.resource.ConsumerResource$$EnhancerByGuice$$8e2e0224$$FastClassByGuice$$ef700700.invoke(<generated>)
	at com.google.inject.internal.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:64)
	at org.fedoraproject.candlepin.auth.interceptor.SecurityInterceptor.invoke(SecurityInterceptor.java:91)
	at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:64)
	at com.google.inject.InterceptorStackCallback.intercept(InterceptorStackCallback.java:44)
	at org.fedoraproject.candlepin.resource.ConsumerResource$$EnhancerByGuice$$8e2e0224.bind(<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:616)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
	... 36 more







Version-Release number of selected component (if applicable):
[root@jsefler-f14-candlepin candlepin]# git show-ref master
bb30cb4b09b6e510f633c9a7a60581c4ddf96272 refs/heads/master
2cc34e37691e9e06aad2ad3da394dabc24186ca7 refs/remotes/origin/master


How reproducible:


Steps to Reproduce:
1. Deploy new candlepin with TESTDATA=1
ssh root.redhat.com export TESTDATA=1; export FORCECERT=1; export GENDB=1; export HOSTNAME=jsefler-f14-candlepin.usersys.redhat.com; export IMPORTDIR=; cd /root/candlepin/proxy; buildconf/scripts/deploy

2. On a virt guest client, copy all the generated products from the server
[root@jsefler-onprem03 ~]# virt-what
kvm

[root@jsefler-onprem03 ~]# ls /etc/pki/product/
100000000000000.pem  132.pem  27060.pem  37062.pem  37067.pem  37069.pem  37080.pem  917571.pem
1144.pem             1.pem    37060.pem  37065.pem  37068.pem  37070.pem  37090.pem

3. register with autosubscribe
[root@jsefler-onprem03 ~]# subscription-manager register --username=testuser1 --password=password --autosubscribe 
131663f2-dde3-455c-a88e-4bbc912c74a6 jsefler-onprem03.usersys.redhat.com

  
^^^^ Expected some output telling me that products were subscribed.
Instead the server's log contains the NPE above.

Comment 1 John Sefler 2011-02-24 20:36:53 UTC
[root@jsefler-f14-candlepin proxy]# git show-ref master
a884304ce0cb9f9a399961619ba41c6bd8c05c37 refs/heads/master
2cc34e37691e9e06aad2ad3da394dabc24186ca7 refs/remotes/origin/master

Not sure what changed between master git hashes a884304ce0cb9f9a399961619ba41c6bd8c05c37 and bb30cb4b09b6e510f633c9a7a60581c4ddf96272, but the NullPointerException seems to have disappeared.

3. register with autosubscribe is wororking again
[root@jsefler-onprem03 ~]# subscription-manager register --username=testuser1 --password=password --autosubscribe
9a63ba95-4f0f-47da-b645-69cc3915e2bd jsefler-onprem03.usersys.redhat.com
Installed Products:
   Multiplier Product Bits - Not Subscribed
   Load Balancing Bits - Subscribed
   Awesome OS Server Bits - Subscribed
   Management Bits - Subscribed
   Awesome OS Scalable Filesystem Bits - Subscribed
   Shared Storage Bits - Subscribed
   Large File Support Bits - Subscribed
   Awesome OS Workstation Bits - Subscribed
   Awesome OS Premium Architecture Bits - Not Subscribed
   Awesome OS for S390X Bits - Not Subscribed
   Awesome OS Developer Basic - Not Subscribed
   Clustering Bits - Subscribed
   Awesome OS Developer Bits - Not Subscribed
   Awesome OS Modifier Bits - Subscribed


Leaving bug state as NEW for dev to look at the stack trace and see if there's something to be fixed. Otherwise this is currently working for me.

Comment 2 Justin Harris 2011-03-04 20:18:31 UTC
I'm not exactly sure why this was happening in the first place, but I added a quick null check to make sure that auto-subscribing to a non-existent product doesn't blow up like that.  This will just silently skip those products though, so you may not have all of the subscriptions that you want.  This might be due to the test data and the generated certs getting out of sync.

Commit:  8bc35af0addf736ad5366fbad92f188b92701271

Comment 3 John Sefler 2011-03-10 21:37:40 UTC
Verifying Version....
[root@jsefler-f14-candlepin candlepin]# git show-ref 0.2
3a300aa9e5724df9602995b5631be1e941b69d2d refs/heads/0.2
9c13d6bf6d83070bbc78638f6ca3bc1dc5267977 refs/remotes/origin/0.2

[root@jsefler-f14-candlepin candlepin]# git log | grep 8bc35af0addf736ad5366fbad92f188b92701271
commit 8bc35af0addf736ad5366fbad92f188b92701271



[root@jsefler-onprem03 bug629670]# subscription-manager register --username=testuser1 --password=password --autosubscribe
ca79f558-8c9c-438a-892a-029102c02a44 jsefler-onprem03.usersys.redhat.com
Installed Products:
   Awesome OS Modifier Bits - Subscribed
   Awesome OS Scalable Filesystem Bits - Subscribed
   Awesome OS Server Bits - Subscribed
   Large File Support Bits - Subscribed
   Management Bits - Subscribed
   Shared Storage Bits - Subscribed
   Clustering Bits - Subscribed
   Load Balancing Bits - Subscribed
   Awesome OS Workstation Bits - Subscribed
   Multiplier Product Bits - Not Subscribed
   Awesome OS Premium Architecture Bits - Not Subscribed
   Awesome OS for S390X Bits - Not Subscribed
   Awesome OS Developer Basic - Not Subscribed
   Awesome OS Developer Bits - Not Subscribed


[root@jsefler-f14-candlepin candlepin]# tail -f /var/log/tomcat6/catalina.out
Mar 10 16:34:56 [http-8443-1] INFO  org.fedoraproject.candlepin.policy.js.entitlement.EntitlementRules - Selecting best entitlement pool for product: [37080, 100000000000000, 37068, 1, 37065, 37090, 1144, 37069, 37060, 27060, 37070, 917571, 37062, 37067]
Mar 10 16:34:56 [http-8443-1] INFO  org.fedoraproject.candlepin.policy.js.entitlement.EntitlementRules - Excuted javascript rule: select_pool_global



NPE was not thrown during the re-create steps.
I'm not confident that this really tested what jharris put in the fix, but the original problem did not happen again.
Moving to VERIFIED.

Comment 4 John Sefler 2011-05-04 14:40:20 UTC
Group move of VERIFIED Candlepin component bugs to RELEASE_PENDING