Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1420406

Summary: [candlepin-2.0] import manifest after delete gives: Runtime Error Index: 0, Size: 0 at java.util.ArrayList.rangeCheck:653
Product: Red Hat Satellite Reporter: Tom McKay <tomckay>
Component: CandlepinAssignee: Michael Stead <mstead>
Status: CLOSED ERRATA QA Contact: Chris Roberts <chrobert>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.0CC: bbuckingham, chrobert, jcallaha, mstead
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:51:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1420455    
Bug Blocks:    

Description Tom McKay 2017-02-08 15:05:35 UTC
To reproduce:
+ import manifest
+ enable repos (not sure required step for reproducer)
+ delete manifest
+ import same manifest

<pre>
2017-02-08 15:01:01,616 [thread=http-bio-8443-exec-6] [req=91ff7192-38db-4370-9111-1389725c6ed1, org=] INFO  org.candlepin.common.filter.LoggingFilter - Request: verb=GET, uri=/candlepin/owners/examplecorp/uebercert
2017-02-08 15:01:01,655 [thread=http-bio-8443-exec-6] [req=91ff7192-38db-4370-9111-1389725c6ed1, org=examplecorp] ERROR org.candlepin.common.exceptions.mappers.CandlepinExceptionMapper - Runtime Error Index: 0, Size: 0 at java.util.ArrayList.rangeCheck:653
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[na:1.8.0_111]
	at java.util.ArrayList.get(ArrayList.java:429) ~[na:1.8.0_111]
	at org.candlepin.resource.OwnerResource.getUeberCertificate(OwnerResource.java:1422) ~[OwnerResource.class:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_111]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_111]
</pre>

Comment 1 Tom McKay 2017-02-08 15:05:41 UTC
Created from redmine issue http://projects.theforeman.org/issues/18424

Comment 3 Tom McKay 2017-02-08 16:12:27 UTC
Debug notes:

SELECT 
       -- NO SUBS FOR 2.0
       
       -- Certificates
       (SELECT Count(*)
        FROM   cp_ent_certificate ec
               INNER JOIN cp_entitlement e
                       ON e.id = ec.entitlement_id
               INNER JOIN cp_pool p
                       ON e.pool_id = p.id
               INNER JOIN cp2_products prod
                       ON prod.uuid = p.product_uuid
        WHERE  prod.NAME LIKE '%_ueber_product') AS UEBER_ENT_CERTS,
        
        -- Entitlements
       (SELECT Count(*)
        FROM   cp_entitlement e
               INNER JOIN cp_pool p
                       ON e.pool_id = p.id
               INNER JOIN cp2_products prod
                       ON prod.uuid = p.product_uuid
        WHERE  prod.NAME LIKE '%_ueber_product') AS UEBER_ENTS,
        
        -- Pools
       (SELECT Count(*)
        FROM   cp_pool p
               INNER JOIN cp2_products prod
                       ON prod.uuid = p.product_uuid
        WHERE  prod.NAME LIKE '%_ueber_product') AS UEBER_POOLS,
        
        -- Content
        (select count(*) from cp2_content c
               inner join cp2_product_content pc on pc.content_uuid=c.uuid
               inner join cp2_products p on p.uuid=pc.product_uuid
               where p.name LIKE '%ueber_product'
        ) AS CP2_UEBER_CONTENT,

        -- Owner Content
        (select count(*) from cp2_owner_content oc
               inner join cp2_content c on c.uuid=oc.content_uuid
               inner join cp2_product_content pc on pc.content_uuid=c.uuid
               inner join cp2_products p on p.uuid=pc.product_uuid
               where p.name LIKE '%ueber_product'
         ) as CP2_OWNER_CONTENT,

         -- Products
         (select count(*) from cp2_products p where p.name LIKE '%ueber_product') AS CP2_PRODUCTS,

         -- Owner Products
         (select count(*) from cp2_owner_products op
             INNER JOIN cp2_products prod on op.product_uuid = prod.uuid
             WHERE prod.name LIKE '%ueber_product'
         ) AS CP2_OWNER_PRODUCTS,

         -- Consumers
         (SELECT Count(*)
             FROM   cp_consumer
             WHERE  NAME = 'ueber_cert_consumer'
         ) AS UEBER_CONSUMER;


Before manifest delete:
 ueber_ent_certs | ueber_ents | ueber_pools | cp2_ueber_content | cp2_owner_content | cp2_products | cp2_owner_products | ueber_consumer 
-----------------+------------+-------------+-------------------+-------------------+--------------+--------------------+----------------
               1 |          1 |           1 |                 1 |                 1 |            1 |                  1 |              1

After manifest delete:
 ueber_ent_certs | ueber_ents | ueber_pools | cp2_ueber_content | cp2_owner_content | cp2_products | cp2_owner_products | ueber_consumer 
-----------------+------------+-------------+-------------------+-------------------+--------------+--------------------+----------------
               0 |          0 |           0 |                 1 |                 1 |            1 |                  1 |              1

Comment 4 Michael Stead 2017-02-09 11:51:33 UTC
Fix is available in candlepin-2.0.25-1

Comment 5 Satellite Program 2018-02-21 16:51:07 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.
> 
> For information on the advisory, and where to find the updated files, follow the link below.
> 
> If the solution does not work for you, open a new bug report.
> 
> https://access.redhat.com/errata/RHSA-2018:0336