Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 874785

Summary: Owner migration fails with null ptr exception
Product: [Community] Candlepin (Migrated to Jira) Reporter: Andrew Edwards <aedwards>
Component: candlepinAssignee: Jesus M. Rodriguez <jesusr>
Status: CLOSED CURRENTRELEASE QA Contact: Katello QA List <katello-qa-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.9CC: bkearney, jesusr, tpfromme
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: 2014-11-07 16:00:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
null pointer migrating owner none

Description Andrew Edwards 2012-11-08 20:33:17 UTC
Description of problem:
Owner migration fails with null pointer exception (See attached stack).

Version-Release number of selected component (if applicable):
0.7.13

How reproducible:
100%

Steps to Reproduce:
1. Create an owner on originating shard
2. Create a consumer for the owner created in step 1
3. create an owner migration job on the destination shard
  
Actual results:
Owner migration fails with null pointer exception 

Expected results:
Owner is successfully migrated from originating shard to destination shard.

Additional info:
exception attached. Exception occurs while attempting to copy over consumer facts. I beleive this is because consumer facts are no longer returned with a owners/<key/consumers call.

migration call used:
curl -u candlepin_admin -X POST "http://bork-s04.candlepin.dev.devlab.phx1.redhat.com:8080/candlepin/migrations?entity=OWNER&id=6302668&uri=bork-s01.candlepin.dev.devlab.phx1.redhat.com:8080/candlepin&delete=true"

Comment 1 Andrew Edwards 2012-11-08 20:34:43 UTC
Created attachment 641075 [details]
null pointer migrating owner

Comment 2 Jesus M. Rodriguez 2012-11-20 15:57:41 UTC
This looks like a n00b coding mistake, but it alludes to a consumer with *NO* facts coming across the wire.

295        for (Consumer consumer : rsp.getEntity()) {
296            log.info("importing consumer: " + consumer.toString());
297
298            log.info("consumer.id: " + consumer.getId());
299            log.info("consumer.entitlements:  " +
300                consumer.getEntitlements().toString());
301            log.info("consumer.facts: " + consumer.getFacts().toString());

it can't be consumer because the lines preceding 301 worked. So this means that getFacts() is null. I will add a unit test and some null checking to this.

Comment 3 Jesus M. Rodriguez 2012-11-21 17:49:48 UTC
Fixed in 0.7.13-hotfix branch: 98dd321e7db604cec29b1eed92b7f13ddeee36ba
Fixed in master: https://github.com/candlepin/candlepin/pull/117

Comment 4 Andrew Edwards 2012-11-28 18:46:44 UTC
Deployed candlepin 0.7.13.4 in dev environment. Migrations still fail but with new location. Exception is below.

Nov 28 17:44:44 [ITClusteredScheduler_Worker-2] ERROR org.quartz.core.JobRunShell - Job async group.migrate_owner_f7a2cf4c-b8a3-4ad4-9d19-ca420dd7ac14 threw an unhandled Exception: 
java.lang.NullPointerException
	at org.candlepin.model.ConsumerCurator.replicate(ConsumerCurator.java:112)
	at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:66)
	at org.candlepin.pinsetter.tasks.MigrateOwnerJob.replicateConsumers(MigrateOwnerJob.java:308)
	at org.candlepin.pinsetter.tasks.MigrateOwnerJob.execute(MigrateOwnerJob.java:156)
	at org.candlepin.pinsetter.core.TransactionalPinsetterJob.execute(TransactionalPinsetterJob.java:50)
	at org.quartz.core.JobRunShell.run(Unknown Source)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(Unknown Source)
Nov 28 17:44:44 [ITClusteredScheduler_Worker-2] ERROR org.quartz.core.ErrorLogger - Job (async group.migrate_owner_f7a2cf4c-b8a3-4ad4-9d19-ca420dd7ac14 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
	at org.quartz.core.JobRunShell.run(Unknown Source)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
	at org.candlepin.model.ConsumerCurator.replicate(ConsumerCurator.java:112)
	at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:66)
	at org.candlepin.pinsetter.tasks.MigrateOwnerJob.replicateConsumers(MigrateOwnerJob.java:308)
	at org.candlepin.pinsetter.tasks.MigrateOwnerJob.execute(MigrateOwnerJob.java:156)
	at org.candlepin.pinsetter.core.TransactionalPinsetterJob.execute(TransactionalPinsetterJob.java:50)
	... 2 more

Comment 5 Jesus M. Rodriguez 2012-11-28 19:55:19 UTC
That's bad. Line 112 is this:

        this.currentSession().replicate(idCert.getSerial(),
            ReplicationMode.EXCEPTION);

That means either the currentSession is null (unlikely) or the idCert is null. Which also means we have a Consumer with no identity certificate. Since idCert is assigned on line 111 above:

        IdentityCertificate idCert = consumer.getIdCert();


(In reply to comment #4)
> Deployed candlepin 0.7.13.4 in dev environment. Migrations still fail but
> with new location. Exception is below.
> 
> Nov 28 17:44:44 [ITClusteredScheduler_Worker-2] ERROR
> org.quartz.core.JobRunShell - Job async
> group.migrate_owner_f7a2cf4c-b8a3-4ad4-9d19-ca420dd7ac14 threw an unhandled
> Exception: 
> java.lang.NullPointerException
> 	at org.candlepin.model.ConsumerCurator.replicate(ConsumerCurator.java:112)
> 	at
> com.google.inject.persist.jpa.JpaLocalTxnInterceptor.
> invoke(JpaLocalTxnInterceptor.java:66)
> 	at
> org.candlepin.pinsetter.tasks.MigrateOwnerJob.
> replicateConsumers(MigrateOwnerJob.java:308)
> 	at
> org.candlepin.pinsetter.tasks.MigrateOwnerJob.execute(MigrateOwnerJob.java:
> 156)
> 	at
> org.candlepin.pinsetter.core.TransactionalPinsetterJob.
> execute(TransactionalPinsetterJob.java:50)
> 	at org.quartz.core.JobRunShell.run(Unknown Source)
> 	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(Unknown Source)
> Nov 28 17:44:44 [ITClusteredScheduler_Worker-2] ERROR
> org.quartz.core.ErrorLogger - Job (async
> group.migrate_owner_f7a2cf4c-b8a3-4ad4-9d19-ca420dd7ac14 threw an exception.
> org.quartz.SchedulerException: Job threw an unhandled exception. [See nested
> exception: java.lang.NullPointerException]
> 	at org.quartz.core.JobRunShell.run(Unknown Source)
> 	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(Unknown Source)
> Caused by: java.lang.NullPointerException
> 	at org.candlepin.model.ConsumerCurator.replicate(ConsumerCurator.java:112)
> 	at
> com.google.inject.persist.jpa.JpaLocalTxnInterceptor.
> invoke(JpaLocalTxnInterceptor.java:66)
> 	at
> org.candlepin.pinsetter.tasks.MigrateOwnerJob.
> replicateConsumers(MigrateOwnerJob.java:308)
> 	at
> org.candlepin.pinsetter.tasks.MigrateOwnerJob.execute(MigrateOwnerJob.java:
> 156)
> 	at
> org.candlepin.pinsetter.core.TransactionalPinsetterJob.
> execute(TransactionalPinsetterJob.java:50)
> 	... 2 more

Comment 6 Bryan Kearney 2014-11-07 16:00:13 UTC
Closing this out. The code was deliverded 0.7.13, and future versions have removed it. If you are still seeing issues.. please feel free to re-open this bug.