Bug 743704

Summary: autosubscribe ignores socket count on non multi-entitle subscriptions
Product: [Community] Candlepin Reporter: J.C. Molet <jmolet>
Component: candlepinAssignee: Chris Duryee <cduryee>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: high Docs Contact:
Priority: unspecified    
Version: 0.5CC: bkearney, cduryee, dgoodwin, jsefler
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: 2012-05-30 13:13:19 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:    
Bug Blocks: 682238    

Description J.C. Molet 2011-10-05 19:02:26 UTC
Description of problem:
Autosubscribe seems to ignore the socket count on non-multi-entitleable subscriptions and subscribes to them anyway. (possibly because the multi-entitlement attribute is non existant?)

Version-Release number of selected component (if applicable):
[root@mgmt5 candlepin]# git show
commit 5340dfd5b25440d227ee22940da712516a4989bb
 (this includes new healing feature)

python-rhsm-0.96.13-1.git.0.a237980.el6.noarch
subscription-manager-firstboot-0.96.13-1.git.0.b1b0502.el6.x86_64
subscription-manager-0.96.13-1.git.0.b1b0502.el6.x86_64
subscription-manager-gnome-0.96.13-1.git.0.b1b0502.el6.x86_64

How reproducible:
always? 

Steps to Reproduce:
1.  Populate candlepin with TESTDATA=1
2.  Copy over 27060.pem to your products folder (may be possible with other products)
3.  Make sure your cpu sockets are 4.  In a /etc/rhsm/facts/override.facts you can add: {"cpu.cpu_socket(s)":"4", "lscpu.cpu_socket(s)":"4"}
4.  Autosubscribe.
  


Actual results:

[root@jmolet-vm0 product]# ls
27060_.pem
[root@jmolet-vm0 product]# subscription-manager list --installed
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+

ProductName:        	Awesome OS Workstation Bits
Version:            	6.1                      
Arch:               	ALL                      
Status:             	Not Subscribed           
Starts:             	                         
Expires:            	                         

[root@jmolet-vm0 product]# cd
[root@jmolet-vm0 ~]# subscription-manager facts --list | grep cpu_socket
cpu.cpu_socket(s): 4
lscpu.cpu_socket(s): 4
[root@jmolet-vm0 ~]# subscription-manager register --user testuser1 --pass password --org admin
The system has been registered with id: b6aea3ae-e8a1-4eff-8f47-8b75da5cf708 

[root@jmolet-vm0 ~]# subscription-manager list --available | grep Workstation -A 7
[root@jmolet-vm0 ~]# # ^^^ THIS TELLS ME I SHOULDN'T BE ABLE TO SUBSCRIBE TO THIS WORKSTATION SUBSCRIPTION, Next command shows it is only a 2 socket sub: 

[root@jmolet-vm0 facts]# curl -k -u admin:admin https://mgmt5.rhq.lab.eng.bos.redhat.com:8443/candlepin/pools/8a90f88f32d31d280132d31e09830675 | json_reformat | grep sockets -B 1 -A 1

      "productId": "awesomeos-workstation-basic",
      "name": "sockets",
      "value": "2",

[root@jmolet-vm0 ~]# subscription-manager list --available --all | grep Workstation -A 7
ProductName:       	Awesome OS Workstation Basic
ProductId:         	awesomeos-workstation-basic
PoolId:            	8a90f88f32d31d280132d31e095f0669
Quantity:          	10                       
Multi-Entitlement: 	No                       
Expires:           	10/03/2012               
MachineType:       	physical                 

--
ProductName:       	Awesome OS Workstation Basic
ProductId:         	awesomeos-workstation-basic
PoolId:            	8a90f88f32d31d280132d31e09830675
Quantity:          	5                        
Multi-Entitlement: 	No                       
Expires:           	10/03/2012               
MachineType:       	physical  
Expected results:

[root@jmolet-vm0 ~]# subscription-manager subscribe --auto
Installed Product Current Status:

ProductName:         	Awesome OS Workstation Bits
Status:               	Subscribed               

[root@jmolet-vm0 ~]# 


Expected Results:
Because of the fact that the Awesome OS Workstation Basic is a subscription for two socket machines, with multi-entitlement = no, and the fact that I have 4 sockets, autosubscribe should NOT subscribe to this subscription.

Additional info:
the multi-entitlement attribute does not exist in the subscription's product attributes:

[root@jmolet-vm0 facts]# curl -k -u admin:admin https://mgmt5.rhq.lab.eng.bos.redhat.com:8443/candlepin/pools/8a90f88f32d31d280132d31e09830675 | json_reformat
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2712  100  2712    0     0   5768      0 --:--:-- --:--:-- --:--:-- 13979
{
  "id": "8a90f88f32d31d280132d31e09830675",
  "attributes": [

  ],
  "owner": {
    "href": "/owners/admin",
    "id": "8a90f88f32d31d280132d31d41040006",
    "key": "admin",
    "displayName": "Admin Owner"
  },
  "providedProducts": [
    {
      "id": "8a90f88f32d31d280132d31e0983067f",
      "productName": "Awesome OS Workstation Bits",
      "productId": "27060",
      "updated": "2011-10-05T08:05:53.667+0000",
      "created": "2011-10-05T08:05:53.667+0000"
    }
  ],
  "startDate": "2011-10-05T00:00:00.000+0000",
  "endDate": "2012-10-04T00:00:00.000+0000",
  "productName": "Awesome OS Workstation Basic",
  "contractNumber": "10",
  "accountNumber": "12331131231",
  "quantity": 5,
  "productId": "awesomeos-workstation-basic",
  "subscriptionId": "8a90f88f32d31d280132d31d71d100b0",
  "consumed": 0,
  "sourceEntitlement": null,
  "href": "/pools/8a90f88f32d31d280132d31e09830675",
  "activeSubscription": true,
  "restrictedToUsername": null,
  "productAttributes": [
    {
      "productId": "awesomeos-workstation-basic",
      "name": "management_enabled",
      "value": "0",
      "id": "8a90f88f32d31d280132d31e09830676",
      "updated": "2011-10-05T08:05:53.667+0000",
      "created": "2011-10-05T08:05:53.667+0000"
    },
    {
      "productId": "awesomeos-workstation-basic",
      "name": "support_type",
      "value": "L1-L3",
      "id": "8a90f88f32d31d280132d31e09830677",
      "updated": "2011-10-05T08:05:53.667+0000",
      "created": "2011-10-05T08:05:53.667+0000"
    },
    {
      "productId": "awesomeos-workstation-basic",
      "name": "type",
      "value": "MKT",
      "id": "8a90f88f32d31d280132d31e09830678",
      "updated": "2011-10-05T08:05:53.667+0000",
      "created": "2011-10-05T08:05:53.667+0000"
    },
    {
      "productId": "awesomeos-workstation-basic",
      "name": "arch",
      "value": "ALL",
      "id": "8a90f88f32d31d280132d31e0983067a",
      "updated": "2011-10-05T08:05:53.667+0000",
      "created": "2011-10-05T08:05:53.667+0000"
    },
    {
      "productId": "awesomeos-workstation-basic",
      "name": "sockets",
      "value": "2",
      "id": "8a90f88f32d31d280132d31e09830679",
      "updated": "2011-10-05T08:05:53.667+0000",
      "created": "2011-10-05T08:05:53.667+0000"
    },
    {
      "productId": "awesomeos-workstation-basic",
      "name": "version",
      "value": "1.0",
      "id": "8a90f88f32d31d280132d31e0983067b",
      "updated": "2011-10-05T08:05:53.667+0000",
      "created": "2011-10-05T08:05:53.667+0000"
    },
    {
      "productId": "awesomeos-workstation-basic",
      "name": "support_level",
      "value": "Standard",
      "id": "8a90f88f32d31d280132d31e0983067c",
      "updated": "2011-10-05T08:05:53.667+0000",
      "created": "2011-10-05T08:05:53.667+0000"
    },
    {
      "productId": "awesomeos-workstation-basic",
      "name": "variant",
      "value": "ALL",
      "id": "8a90f88f32d31d280132d31e0983067e",
      "updated": "2011-10-05T08:05:53.667+0000",
      "created": "2011-10-05T08:05:53.667+0000"
    },
    {
      "productId": "awesomeos-workstation-basic",
      "name": "warning_period",
      "value": "30",
      "id": "8a90f88f32d31d280132d31e0983067d",
      "updated": "2011-10-05T08:05:53.667+0000",
      "created": "2011-10-05T08:05:53.667+0000"
    }
  ],
  "updated": "2011-10-05T08:05:53.667+0000",
  "created": "2011-10-05T08:05:53.667+0000"
}

Comment 1 James Bowes 2011-10-05 19:10:56 UTC
Moving this one to candlepin, the bug will be in select_best_pools js

Comment 2 Devan Goodwin 2011-10-14 17:56:02 UTC
Perhaps not in select best pools, the pool list given to that routine should filter out anything which doesn't pass a rules check before even making the call. pre_sockets should catch it.

Comment 3 Chris Duryee 2011-10-18 19:27:30 UTC
fc2b8bc master 0.4.22+ (candlepin)

Comment 4 John Sefler 2011-11-03 15:32:43 UTC
Verifying Versions...
[root@jsefler-onprem-62server ~]# rpm -q subscription-manager
subscription-manager-0.96.17-1.el6.x86_64
[root@jsefler-onprem-62server ~]# rpm -q python-rhsm
python-rhsm-0.96.15-1.el6.noarch
[root@jsefler-onprem-62candlepin candlepin]# git show | head -1
commit 7cb7dbe8d5e2892dcbcbf3d77a61541ca221c18f
[root@jsefler-onprem-62candlepin candlepin]# curl -k https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/status
{"version":"0.4.25","result":true,"standalone":false,"release":"1"}


[root@jsefler-onprem-62server ~]# subscription-manager register --username testuser1 --password password --org admin
The system has been registered with id: 67cb150f-0084-4f6c-b0d1-a01dc8578ccd 
[root@jsefler-onprem-62server ~]# subscription-manager list --avail | grep Workstation -A7
ProductName:       	Awesome OS Workstation Basic
ProductId:         	awesomeos-workstation-basic
PoolId:            	8a90f805336631120133663293b006cb
Quantity:          	10                       
Multi-Entitlement: 	No                       
Expires:           	11/30/2012               
MachineType:       	physical                 

--
ProductName:       	Awesome OS Workstation Basic
ProductId:         	awesomeos-workstation-basic
PoolId:            	8a90f805336631120133663293f206d7
Quantity:          	5                        
Multi-Entitlement: 	No                       
Expires:           	11/30/2012               
MachineType:       	physical    

[root@jsefler-onprem-62server ~]# curl -k -u admin:admin https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/pools/8a90f805336631120133663293b006cb | python -mjson.tool | grep sockets -A3
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2713    0  2713    0     0  18325      0 --:--:-- --:--:-- --:--:-- 34782
            "name": "sockets", 
            "productId": "awesomeos-workstation-basic", 
            "updated": "2011-11-02T21:32:30.513+0000", 
            "value": "2"
[root@jsefler-onprem-62server ~]# 
[root@jsefler-onprem-62server ~]# subscription-manager facts --list | grep cpu_socket
cpu.cpu_socket(s): 2
lscpu.cpu_socket(s): 2


^^^ ALL OF THAT (sockets:2 satifies my system with 2 socket/Multi-Entitlement:No) IS AN INDICATION THAT AUTOSUBSCRIBE SHOULD SUCCEED.  LET'S PROVE IT...

[root@jsefler-onprem-62server ~]# subscription-manager subscribe --auto
Installed Product Current Status:

ProductName:         	Awesome OS Workstation Bits
Status:               	Subscribed  

^^^ YES, AUTOSUBSCRIBE WORKS ON A non-multi-entitlement POOL WITH SATISFYING SOCKET COUNT.  NOW FOR THE REAL TEST; LET'S INCREASE THE SOCKET COUNT AND RETEST...

[root@jsefler-onprem-62server ~]# subscription-manager unregister
This system is currently not registered.
[root@jsefler-onprem-62server ~]# cat /etc/rhsm/facts/sockets.facts 
{"cpu.cpu_socket(s)": "6","lscpu.cpu_socket(s)": "6"}
[root@jsefler-onprem-62server ~]# subscription-manager facts --list | grep cpu_socket
cpu.cpu_socket(s): 6
lscpu.cpu_socket(s): 6
[root@jsefler-onprem-62server ~]# subscription-manager register --username testuser1 --password password --org admin --autosubscribe
The system has been registered with id: cd1d9bad-dd9e-4c4d-a493-40f0d5647d13 
Installed Product Current Status:

ProductName:         	Awesome OS Workstation Bits
Status:               	Not Subscribed           

[root@jsefler-onprem-62server ~]# subscription-manager subscribe --auto
Installed Product Current Status:

ProductName:         	Awesome OS Workstation Bits
Status:               	Not Subscribed           

[root@jsefler-onprem-62server ~]# subscription-manager list --avail | grep Workstation -A7
[root@jsefler-onprem-62server ~]# subscription-manager list --avail --all | grep Workstation -A7
ProductName:       	Awesome OS Workstation Basic
ProductId:         	awesomeos-workstation-basic
PoolId:            	8a90f805336631120133663293b006cb
Quantity:          	10                       
Multi-Entitlement: 	No                       
Expires:           	11/30/2012               
MachineType:       	physical                 

--
ProductName:       	Awesome OS Workstation Basic
ProductId:         	awesomeos-workstation-basic
PoolId:            	8a90f805336631120133663293f206d7
Quantity:          	5                        
Multi-Entitlement: 	No                       
Expires:           	11/30/2012               
MachineType:       	physical                 

[root@jsefler-onprem-62server ~]# 


^^^  VERIFIED that when sockets on the machine exceed the non-multi entitlement subscription that covers our installed product, autosubscribe will not use that pool and the pool is filtered from the list --avail. 

moving to VERIFIED