Bug 784665 - Unable to delete pools referenced by activation keys
Summary: Unable to delete pools referenced by activation keys
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Subscription Asset Manager
Classification: Retired
Component: katello
Version: 1.0.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Tom McKay
QA Contact: Tazim Kolhar
URL:
Whiteboard:
Depends On:
Blocks: sam11-tracker 810945
TreeView+ depends on / blocked
 
Reported: 2012-01-25 18:12 UTC by James Bowes
Modified: 2016-04-26 00:54 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 810945 (view as bug list)
Environment:
Last Closed: 2012-08-21 18:29:11 UTC
Embargoed:
tomckay: automate_bug? (esammons)


Attachments (Terms of Use)
Deleting the pools referenced by the activation keys. (134.07 KB, image/png)
2012-05-15 09:53 UTC, Tazim Kolhar
no flags Details

Description James Bowes 2012-01-25 18:12:35 UTC
activation keys have a foreign key constrain on pools they reference. there's no logic to delete this link or key when you delete a pool, so trying to delete a pool referenced by an activation key will cause an exception.

This is particularly bad for pools that virt only and derived from a host entitlement. When you attempt to unregister the host, the pool is deleted, but if a key references it, the entire pool deletion and unregistration will result in an exception.

We should probably automatically remove the reference in the activation key to the pool

Comment 2 Chris Duryee 2012-02-23 19:55:58 UTC
419e8d3 master 0.5.23+

Comment 3 yu zheng 2012-04-06 09:03:18 UTC
verifying...
1.Register host to SAM and start virt-who. Host consumes a subscription and a bonus pool produces.
2.Register a guest of the host to SAM. Check guest's available pools.
# headpin -u admin -p admin system subscriptions --org=ACME_Corporation --name=localhost.localdomain --available
......
PoolId:            8ac287a3366787b90136866f60923bba
                                          ^^^^^^^^^the bonus pool
PoolName:          Red Hat Enterprise Linux Workstation, Standard
Expires:           2012-07-05
Consumed:          0
Quantity:          1
Sockets:           
MultiEntitlement:  False
Provided products: Red Hat Enterprise Linux Workstation
......

3.Create an actication key and add a bonus pool to the key.
# headpin -u admin -p admin activation_key create --org=ACME_Corporation --name=testkey --environment=env1
Successfully created activation key [ testkey ]
# headpin -u admin -p admin activation_key update --org=ACME_Corporation --name=testkey --add_subscription=8ac287a3366787b90136866f60923bba
Successfully updated activation key [ testkey ]

4.Unsubscribe the host.
# subscription-manager unsubscribe --all

5.Check activation key's info.
# headpin -u admin -p admin activation_key info --org=ACME_Corporation --name=testkey
---------------------------------------------------------
         Activation Key Info
------------------------------------------------------
Id:                 1
Name:               testkey
Description:        None
Environment Id:     2
System Template Id: None
Pools:
    [ 8ac287a3366787b90136866f60923bba ]
                  ^^^^^^^^^^^^^^^^^^^^^^the bonus pool is revoked successfully, but it's not removed from the actication key.

Comment 4 Chris Duryee 2012-04-09 17:23:00 UTC
The behavior in comment #3 appears to be a katello/headpin issue, I am able to replicate it with a sam installation, but not with a bare candlepin.

Moving to katello component.

Comment 5 Tom McKay 2012-04-27 17:54:12 UTC
Testcase Scenarios
==================

1. Register a system and consume a subscription that generates a bonus pool
2. Add this bonus pool to an activation key
3. Unsubscribe the first subscription (thus eliminating the bonus pool)
4. View/query the activation key to confirm bonus pool was removed


1. Import a manifest with a subscription in it
2. Add this sub to an activation key
3. Import a new manifest w/o that pool in it
4. View/query the activation key to confirm bonus pool was removed

Comment 6 Tazim Kolhar 2012-05-15 09:53:29 UTC
Created attachment 584615 [details]
Deleting the pools referenced by the activation keys.

VERIFIED with the build :

[root@hp-dl360g6-01 ~]# rpm -qa | grep katello
katello-cli-headpin-0.2.0-1.el6_2.noarch
katello-glue-candlepin-0.3.1-1.el6_2.noarch
katello-candlepin-cert-key-pair-1.0-1.noarch
katello-cli-common-0.3.2-3.el6_2.noarch
katello-selinux-0.2.4-1.el6_2.noarch
katello-headpin-0.2.6-4.el6_2.noarch
katello-certs-tools-1.1.5-1.el6_2.noarch
katello-configure-0.3.3-2.el6_2.noarch
katello-common-0.3.1-1.el6_2.noarch
katello-headpin-all-0.2.6-4.el6_2.noarch

1.) import a manifests and subscribed it to a activation key.
2.) import another manifests without that pool in it .
3.) the pool is removed from the activation key as well.


Note You need to log in before you can comment on or make changes to this bug.