Bug 663455 - Candlepin Rules Block Future Entitling
Summary: Candlepin Rules Block Future Entitling
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Candlepin
Classification: Community
Component: candlepin
Version: 0.5
Hardware: Unspecified
OS: Solaris
low
high
Target Milestone: ---
: ---
Assignee: Devan Goodwin
QA Contact: John Sefler
URL:
Whiteboard:
Depends On:
Blocks: Entitlement-Beta
TreeView+ depends on / blocked
 
Reported: 2010-12-15 20:42 UTC by Devan Goodwin
Modified: 2015-05-14 15:22 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-02-23 21:51:38 UTC


Attachments (Terms of Use)
demonstrates that I can be "triple" subscribed to the same product without getting blocked by a "you are already subscribed to this product" dialog. (50.48 KB, image/png)
2011-01-25 17:44 UTC, John Sefler
no flags Details
shows compliance of "RHEL for Workstations SVC" after using "Become Compliant" to subscribe to a two pools valid today and in the future. (75.17 KB, image/png)
2011-01-25 17:56 UTC, John Sefler
no flags Details
shows both the current and future subscriptions I used in the compliance tool that overlap the compliance of "RHEL for Workstations SVC" (54.09 KB, image/png)
2011-01-25 17:59 UTC, John Sefler
no flags Details

Description Devan Goodwin 2010-12-15 20:42:30 UTC
Description of problem:

A Candlepin default rule to prevent multiple entitlements to one product is blocking attempts to "become compliant" on a date in the future by grabbing an entitlement to a future dated subscription if the marketing SKU is still the same.


How reproducible:

100%

Steps to Reproduce:
1. Use the cp_product_utils test data which creates two subscriptions for the next year, and one for the following year.
2. Use an entitlement for one of the subscriptions valid for the next year.
3. Enter the compliance assistant and search for subscriptions on the day after the current subscription will expire.
4. Try to subscribe to a future subscription with the exact same marketing SKU.
  
Actual results:

Entitlement is blocked with an error about already consuming the product in this pool.

Expected results:

The entitlement should be granted provided it is for a future entitlement.


Additional info:

This will be quite tricky, we had to do date overlap comparisons, but it is very likely the two subscriptions will sometimes overlap somewhat. We may have to query to see if the consumer has an entitlement for this product, which does not overlap beyond say a day/week/month *into* the start date of the subscription being requested.

Comment 1 Devan Goodwin 2011-01-11 21:11:37 UTC
So the rule blocking this is:

if (consumer.hasEntitlement(product) && product.getAttribute("multi-entitlement") != "yes") {
    pre.addError("rulefailed.consumer.already.has.product");
}

Which obviously will block any attempt to grab a future dated entitlement to keep you compliant with something you already have, if the product is exactly the same.

I would like to avoid a situation where we start playing with date checking if possible, as the subscriptions will probably often overlap, which means we likely need to figure out how much overlap counts as an attempt to multi-entitle.

I propose we change this rule to instead, check if the consumer has an entitlement from the *exact* pool being requested. In essence we block multiple entitlements from one subscription, rather than any subscription for that product ID. 

The downside to this would be allowing a customer who had two subscriptions to the same product with similar dates to consume an entitlement from each. As far as I know this won't harm anything, and the tools should prevent them from accidentally doing this unless they explicitly want to do so. In that light it seems like the easiest way to allow future entitling, and would allow us to avoid trying to make sense of the dates and what counts as overlap.

Thoughts?

Comment 2 Devan Goodwin 2011-01-13 20:00:55 UTC
Above proposal was agreed upon.

Fixed in candlepin.git master: 57e9ce3a1a7a351a9127d37d3bb31cd82803353b
BETA branch: dd1848ab8abec5c8d07bf2bf5f1b43d5d4d394ac

Comment 3 John Sefler 2011-01-25 17:41:17 UTC
Verifying Version...
[root@jsefler-onprem01 ~]# rpm -qa | grep subscription-manager
subscription-manager-firstboot-0.93.14-1.git.9.304e707.el6.x86_64
subscription-manager-0.93.14-1.git.9.304e707.el6.x86_64
subscription-manager-gnome-0.93.14-1.git.9.304e707.el6.x86_64

To verify this bug, I will use an on-premises candlepin with the cp_product_utils imported to provide the following product with overlapping dates:
ProductName:        	Smart Management Add On  
ContractNumber:     	45                                         
Begins:             	2011-01-24               
Expires:            	2012-01-24               

ProductName:        	Smart Management Add On  
ContractNumber:     	46                                          
Begins:             	2011-01-24               
Expires:            	2012-01-24  

ProductName:        	Smart Management Add On  
ContractNumber:     	47                                         
Begins:             	2012-01-14               
Expires:            	2013-01-13               

Using the GUI, I can now "triple" subscribe to all pools that provide the same product. See attached screen shot.


And, if I go to the command line and try to individually subscribe to the pools again, I will get blocked as expected.
[root@jsefler-onprem01 ~]# subscription-manager subscribe --pool=ff8080812dbb8d4d012dbb8ef8000212
This consumer is already subscribed to the product matching pool with id 'ff8080812dbb8d4d012dbb8ef8000212'
[root@jsefler-onprem01 ~]# subscription-manager subscribe --pool=ff8080812dbb8d4d012dbb8ef8190214
This consumer is already subscribed to the product matching pool with id 'ff8080812dbb8d4d012dbb8ef8190214'
Note: It's no so easy to attempt to subscribe to the pool whose dates are valid in the future because the the cli tool currently excludes subscriptions in list --all --available that are not valid today/now. I'll assume that if I knew its pool, I would also get blocked by an attempt to subscribe to it too.

Comment 4 John Sefler 2011-01-25 17:44:07 UTC
Created attachment 475228 [details]
demonstrates that I can be "triple" subscribed to the same product without getting blocked by a "you are already subscribed to this product" dialog.

Comment 5 John Sefler 2011-01-25 17:53:56 UTC
Using the Compliance assistant and generated product certs copied from the onpremises candlepin server (proxy/generated_certs to /etc/pki/product), I am also able to "Become Compliant" to product "RHEL for Workstations SVC" with a RHEL Workstation" subscription that is available today, AND I am also able to use "Become Compliant" to subscribe to another contract that starts in the future.

See the next two attached screenshots.

Comment 6 John Sefler 2011-01-25 17:56:34 UTC
Created attachment 475229 [details]
shows compliance of "RHEL for Workstations SVC" after using "Become Compliant" to subscribe to a two pools valid today and in the future.

Comment 7 John Sefler 2011-01-25 17:59:29 UTC
Created attachment 475230 [details]
shows both the current and future subscriptions I used in the compliance tool that overlap the compliance of "RHEL for Workstations SVC"

Comment 8 John Sefler 2011-01-25 18:00:07 UTC
moving to VERIFIED


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