Bug 679617 - virt_only pools loose their multiplied virt_limit quantity when refresh_pools is applied
Summary: virt_only pools loose their multiplied virt_limit quantity when refresh_pools...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Candlepin
Classification: Community
Component: candlepin
Version: 0.5
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: ---
Assignee: Devan Goodwin
QA Contact: John Sefler
URL:
Whiteboard:
Depends On:
Blocks: 568421
TreeView+ depends on / blocked
 
Reported: 2011-02-23 00:45 UTC by John Sefler
Modified: 2015-05-14 15:22 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-05-30 20:44:23 UTC


Attachments (Terms of Use)

Description John Sefler 2011-02-23 00:45:04 UTC
Description of problem:
virt_only product subscription pools should be generated with an entitlement quantity equal to its originating subscription quantity times the virt_limit value of the product.


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


Steps to Reproduce:
1. deployed a new OnPremises candlepin with TESTDATA=1, 
2. on a configured rhsm client running as a virt guest, register and list the virt_only pools...
[root@jsefler-onprem03 ~]# subscription-manager register --username=testuser1 --password=password
33983ad7-26f6-4468-b3cc-9c5611c9aef7 jsefler-onprem03.usersys.redhat.com
[root@jsefler-onprem03 ~]# subscription-manager list --available --all | grep -A3 -B1 awesomeos-virt-4
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e4fdbe8012e4fdc6b67013b
Quantity:          	10                       
Expires:           	2012-02-21               
--
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e4fdbe8012e4fdc6b8d013e
Quantity:          	40                       
Expires:           	2012-02-21               
--
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e4fdbe8012e4fdc6ba70144
Quantity:          	5                        
Expires:           	2012-02-21               
--
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e4fdbe8012e4fdc6bcb0147
Quantity:          	20                       
Expires:           	2012-02-21               

^^^ Notice the two pools with quantity 40 and 20.  These are the virt_only guest pools.  Their quantity is equal to the virt-limit of 4 times the quantity of their host pools.

NOW, UPDATE ANY ONE SUBSCRIPTION IN THE DATABASE USING SQL (I changed a startDate)...

201102221931:07.455 - INFO: About to change the startDate in the database for this subscription pool: subscriptionName='Awesome OS Server Bundled' productId='awesomeos-server' poolId='8a90f8b42e4fdbe8012e4fdc708801fa' quantity='10' endDate='2012-02-22'
201102221931:07.458 - FINE: Executing SQL: update cp_subscription set startdate='2011-01-21' where id=(select pool.subscriptionid from cp_pool pool where pool.id='8a90f8b42e4fdbe8012e4fdc708801fa');
201102221931:07.552 - INFO: Asserted: Actual value of '1' matches expected value: Updated one row of the cp_subscription table with sql: update cp_subscription set startdate='2011-01-21' where id=(select pool.subscriptionid from cp_pool pool where pool.id='8a90f8b42e4fdbe8012e4fdc708801fa'); 

NOW, REFRESH THE POOLS...
201102221933:19.356 - INFO: curl -k -u admin:admin --request PUT https://jsefler-f14-candlepin.usersys.redhat.com:8443/candlepin/owners/admin/subscriptions 

AND NOW, list --available SHOWS THAT THE virt_only POOLS HAVE LOST THEIR MULTIPLIED VIRT_LIMIT QUANTITY...
[root@jsefler-onprem03 ~]# subscription-manager list --available --all | grep -A3 -B1 awesomeos-virt-4
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e4fdbe8012e4fdc6b67013b
Quantity:          	10                       
Expires:           	2012-02-21               
--
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e4fdbe8012e4fdc6ba70144
Quantity:          	5                        
Expires:           	2012-02-21               
--
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e4fdbe8012e4fdc6b8d013e
Quantity:          	10                       
Expires:           	2012-02-21               
--
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e4fdbe8012e4fdc6bcb0147
Quantity:          	5                        
Expires:           	2012-02-21 


^^ NOTICE THE Quantity of 40 and 20 have been knocked down to 10 and 5 for pools 8a90f8b42e4fdbe8012e4fdc6b8d013e and 8a90f8b42e4fdbe8012e4fdc6bcb0147 respectively.  That's a bug.

Comment 1 John Sefler 2011-02-25 13:30:37 UTC
Something else to be aware of...
Here is an excerpt from a last night's automated test log that coincidently tried to overconsume entitlements from the virt_guest pool...  the result was free entitlements; that's bad for business.



Now we will attempt to subscribe both clients (only one should succeed) concurrently to pool: subscriptionName='Awesome OS with up to 4 virtual guests' productId='awesomeos-virt-4' poolId='8a90f8b42e5b543a012e5b54ba320144' quantity='1' endDate='2012-02-24'
ssh root.redhat.com subscription-manager subscribe --pool=8a90f8b42e5b543a012e5b54ba320144
ssh root.redhat.com subscription-manager subscribe --pool=8a90f8b42e5b543a012e5b54ba320144
ssh root.redhat.com subscription-manager list --all --available
Stdout:
+-------------------------------------------+
Available Subscriptions
+-------------------------------------------+


ProductName: Awesome OS with up to 4 virtual guests
ProductId: awesomeos-virt-4
PoolId: 8a90f8b42e5b543a012e5b54b9f0013b
Quantity: 200
Expires: 2012-02-24


ProductName: Awesome OS with up to 4 virtual guests
ProductId: awesomeos-virt-4
PoolId: 8a90f8b42e5b543a012e5b54ba320144
Quantity: -1
Expires: 2012-02-24 


^^^ Notice the quantity went below zero

Comment 2 Devan Goodwin 2011-03-02 15:44:00 UTC
Comment 1 we believe is a separate issue which should now be fixed.

Original bug should be fixed in Candlepin master as of: 13f6d725f66940863f73b6eb36b51769bd3fee24

I believe this will appear in: candlepin-0.2.10.

Comment 3 John Sefler 2011-03-07 16:17:22 UTC
Agreed... Comment #1 is a separate issue and now appears to be fixed in our nightly automated test runs.

Comment 4 John Sefler 2011-03-07 16:18:35 UTC
Verifying fix for Comment #0

Verifying Version...
[root@jsefler-f14-candlepin candlepin]# git show-ref master
8bc35af0addf736ad5366fbad92f188b92701271 refs/heads/master
2cc34e37691e9e06aad2ad3da394dabc24186ca7 refs/remotes/origin/master
[root@jsefler-onprem03 ~]# rpm -qa | grep  subscription-manager
subscription-manager-gnome-0.95.3-1.git.10.4ec14b7.el6.x86_64
subscription-manager-firstboot-0.95.3-1.git.10.4ec14b7.el6.x86_64
subscription-manager-0.95.3-1.git.10.4ec14b7.el6.x86_64


[root@jsefler-onprem03 ~]# subscription-manager list --available --all | grep -A3 -B1 awesomeos-virt-4
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e90f9be012e90fa4eda0134
Quantity:          	10                       
Expires:           	2012-03-05               
--
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e90f9be012e90fa4f000136
Quantity:          	40                       
Expires:           	2012-03-05               
--
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e90f9be012e90fa4f46013d
Quantity:          	5                        
Expires:           	2012-03-05               
--
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e90f9be012e90fa4f6c0142
Quantity:          	20                       
Expires:           	2012-03-05      


201103071047:52.564 - INFO: Subscribing to subscription pool: subscriptionName='Awesome OS with up to 4 virtual guests' productId='awesomeos-virt-4' poolId='8a90f8b42e90f9be012e90fa4eda0134' quantity='10' endDate='2012-03-05'
201103071047:52.567 - FINE: ssh root.redhat.com subscription-manager subscribe --pool=8a90f8b42e90f9be012e90fa4eda0134 


201103071051:55.253 - INFO: Now we will change the start and end date of the subscription pool adding one month to enddate and subtracting one month from startdate... 
201103071052:00.821 - FINE: Executing SQL: update cp_subscription set enddate='2012-04-05' where id=(select pool.subscriptionid from cp_pool pool where pool.id='8a90f8b42e90f9be012e90fa4eda0134'); 
201103071052:00.995 - INFO: Asserted: Actual value of '1' matches expected value: Updated one row of the cp_subscription table with sql: update cp_subscription set enddate='2012-04-05' where id=(select pool.subscriptionid from cp_pool pool where pool.id='8a90f8b42e90f9be012e90fa4eda0134'); 
201103071052:01.003 - FINE: Executing SQL: update cp_subscription set startdate='2011-02-06' where id=(select pool.subscriptionid from cp_pool pool where pool.id='8a90f8b42e90f9be012e90fa4eda0134'); 
201103071052:01.133 - INFO: Asserted: Actual value of '1' matches expected value: Updated one row of the cp_subscription table with sql: update cp_subscription set startdate='2011-02-06' where id=(select pool.subscriptionid from cp_pool pool where pool.id='8a90f8b42e90f9be012e90fa4eda0134'); 


201103071052:08.941 - INFO: Now let's refresh the subscription pools... 
201103071052:11.740 - INFO: SSH alternative to HTTP request: curl -k -u admin:admin --request PUT https://jsefler-f14-candlepin.usersys.redhat.com:8443/candlepin/owners/admin/subscriptions 

NOW LET'S LIST --all --available POOLS AND ASSERT THAT THE VIRT GUEST POOLS' QUANTITY DID NOT GET CLOBBERED...

[root@jsefler-onprem03 ~]# subscription-manager list --available --all | grep -A3 -B1 awesomeos-virt-4
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e90f9be012e90fa4f46013d
Quantity:          	5                        
Expires:           	2012-03-05               
--
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e90f9be012e90fa4f6c0142
Quantity:          	20                       
Expires:           	2012-03-05               
--
ProductName:       	Awesome OS with up to 4 virtual guests
ProductId:         	awesomeos-virt-4         
PoolId:            	8a90f8b42e90f9be012e90fa4f000136
Quantity:          	40                       
Expires:           	2012-04-05  

^^^ THE VIRT_GUEST POOLS' QUANTITY OF 40 AND 20 REMAIN IN TACT AND THE SUBSCRIBED TO HOST POOL 8a90f8b42e90f9be012e90fa4eda0134 IS NO LONGER LISTED IN THE --list --available.

moving to VERIFIED.

Comment 5 John Sefler 2011-05-04 14:41:16 UTC
Group move of VERIFIED Candlepin component bugs to RELEASE_PENDING


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