Bug 664847

Summary: Autobind logic should respect the architecture attribute
Product: [Community] Candlepin Reporter: Bryan Kearney <bkearney>
Component: candlepinAssignee: Bryan Kearney <bkearney>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: medium Docs Contact:
Priority: low    
Version: 0.5Keywords: QA-Closed
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: 2011-02-23 21:51:26 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: 639436    

Description Bryan Kearney 2010-12-21 20:35:18 UTC
Autobind should respect the architecture attribute. Running autobind on an x86_64 machine should not select a ppc product.

Comment 1 Bryan Kearney 2011-01-24 19:45:41 UTC
fixed in c3c7c53ac977aad5b72dd14888a0b5d577334198

Will require a candlepin rebuild

Comment 2 John Sefler 2011-02-16 19:17:49 UTC
VERIFYING VERSION....
[root@jsefler-f12-candlepin candlepin]# git branch
  ALPHA
* BETA
  master
[root@jsefler-f12-candlepin candlepin]# git show-ref BETA
379580b09a7e14d17a17b09fb665518dd0036b97 refs/heads/BETA
3b0042c82f8277ef3cc1e81771b0c19181721fa7 refs/remotes/origin/BETA



[root@jsefler-onprem01 ~]# subscription-manager facts --list | grep arch
cpu.architecture: x86_64
[root@jsefler-onprem01 ~]# subscription-manager list --available  | grep -A4 s390x
[root@jsefler-onprem01 ~]# 

NOTE THAT list --available RETURNED NO AVAILABLE POOLS MATCHING s390X SINCE OUR SYSTEM IS x86_64. YET list --all --available SHOWS s390x POOLS AS SHOWN HERE...

[root@jsefler-onprem01 ~]# subscription-manager list --available --all | grep -A4 s390x
ProductName:       	PRAD390 Awesome OS for IBM s390x systems Product
ProductId:         	MKT-prads-awesome-s390x-os
PoolId:            	ff8080812e2fb2cc012e2fb44f6201c0
Quantity:          	5                        
Expires:           	2012-02-15               

--
ProductName:       	PRAD390 Awesome OS for IBM s390x systems Product
ProductId:         	MKT-prads-awesome-s390x-os
PoolId:            	ff8080812e2fb2cc012e2fb44f7301c4
Quantity:          	10                       
Expires:           	2012-02-15               


NOW LET'S FORCE THE SYSTEM ARCH FACTS TO BE s390x...

[root@jsefler-onprem01 ~]# echo '{"cpu.architecture": "s390x"}' > /etc/rhsm/facts/test.facts
[root@jsefler-onprem01 ~]# subscription-manager facts --list | grep arch
cpu.architecture: s390x

[root@jsefler-onprem01 ~]# subscription-manager facts --update
6404b3e2-914e-4dca-a083-77d9990d2b63
[root@jsefler-onprem01 ~]# subscription-manager list --available  | grep -A4 s390x
ProductName:       	PRAD390 Awesome OS for IBM s390x systems Product
ProductId:         	MKT-prads-awesome-s390x-os
PoolId:            	ff8080812e2fb2cc012e2fb44f6201c0
Quantity:          	5                        
Expires:           	2012-02-15               

--
ProductName:       	PRAD390 Awesome OS for IBM s390x systems Product
ProductId:         	MKT-prads-awesome-s390x-os
PoolId:            	ff8080812e2fb2cc012e2fb44f7301c4
Quantity:          	10                       
Expires:           	2012-02-15     


^^^ 
NOW list --availble FINDS MATCHES AGAINST s390x


This bug is partially verified.  We should still do an autosubscribe.

Comment 3 John Sefler 2011-02-16 20:31:43 UTC
Strategy to finish verification of this bug...
1. hand edit all of the product subscriptions in the cp_product_utils setting the arch field to "arch664847"
2. redeploy the onpremise candlepin server
3. autosubscribe from a client whose arch is NOT arch664847 and assert that NONE of the installed products are subscribed.
4. trick the client facts into believing that its arch is "arch664847"
5. autosubscribe against and assert that AT LEAST ONE of the currently installed products is Subscribed.


Ready set go...
1. I copied my cp_product_utils directory to cp_product_utils_bug664847 and hand edited the subscription changing the seventh attribute. for example in import_products.json :

   "products": [
        [
            "ha",
            "High availability (cluster suite)",
            "37065",
            1,
            "1.0",
            "ALL",
            "arch664847",
            "SVC",
            [],
            {
                "sockets": 2
            },
            [
                [
                    0,
                    false
                ],
                [
                    1,
                    true
                ]
            ]
        ],

2. Now I redeployed my server and greped the output to show the arch: arch664847 being imported...

[root@jsefler-f12-candlepin proxy]# export TESTDATA=0; export FORCECERT=1; export GENDB=1; export HOSTNAME=jsefler-f12-candlepin.usersys.redhat.com; export IMPORTDIR=/root/cp_product_utils_bug664847; cd /root/candlepin/proxy; buildconf/scripts/deploy | egrep "^product name:"
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_cert_serial_pkey" for table "cp_cert_serial"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_certificate_pkey" for table "cp_certificate"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_consumer_pkey" for table "cp_consumer"
NOTICE:  CREATE TABLE / UNIQUE will create implicit index "cp_consumer_uuid_key" for table "cp_consumer"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_consumer_entitlements_pkey" for table "cp_consumer_entitlements"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_consumer_facts_pkey" for table "cp_consumer_facts"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_consumer_type_pkey" for table "cp_consumer_type"
NOTICE:  CREATE TABLE / UNIQUE will create implicit index "cp_consumer_type_label_key" for table "cp_consumer_type"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_content_pkey" for table "cp_content"
NOTICE:  CREATE TABLE / UNIQUE will create implicit index "cp_content_label_key" for table "cp_content"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_ent_certificate_pkey" for table "cp_ent_certificate"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_entitlement_pkey" for table "cp_entitlement"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_event_pkey" for table "cp_event"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_export_metadata_pkey" for table "cp_export_metadata"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_id_cert_pkey" for table "cp_id_cert"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_job_pkey" for table "cp_job"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_key_pair_pkey" for table "cp_key_pair"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_owner_pkey" for table "cp_owner"
NOTICE:  CREATE TABLE / UNIQUE will create implicit index "cp_owner_account_key" for table "cp_owner"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_pool_pkey" for table "cp_pool"
NOTICE:  CREATE TABLE / UNIQUE will create implicit index "cp_pool_subscriptionid_key" for table "cp_pool"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_pool_attribute_pkey" for table "cp_pool_attribute"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_pool_entitlements_pkey" for table "cp_pool_entitlements"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_pool_products_pkey" for table "cp_pool_products"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_product_pkey" for table "cp_product"
NOTICE:  CREATE TABLE / UNIQUE will create implicit index "cp_product_name_key" for table "cp_product"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_product_attribute_pkey" for table "cp_product_attribute"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_product_certificate_pkey" for table "cp_product_certificate"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_product_content_pkey" for table "cp_product_content"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_rules_pkey" for table "cp_rules"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_subscription_pkey" for table "cp_subscription"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_subscription_products_pkey" for table "cp_subscription_products"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_subscription_token_pkey" for table "cp_subscription_token"
NOTICE:  CREATE TABLE / UNIQUE will create implicit index "cp_subscription_token_token_key" for table "cp_subscription_token"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "cp_user_pkey" for table "cp_user"
NOTICE:  CREATE TABLE / UNIQUE will create implicit index "cp_user_username_key" for table "cp_user"
ERROR:  table "qrtz_job_listeners" does not exist
ERROR:  table "qrtz_trigger_listeners" does not exist
ERROR:  table "qrtz_fired_triggers" does not exist
ERROR:  table "qrtz_paused_trigger_grps" does not exist
ERROR:  table "qrtz_scheduler_state" does not exist
ERROR:  table "qrtz_locks" does not exist
ERROR:  table "qrtz_simple_triggers" does not exist
ERROR:  table "qrtz_cron_triggers" does not exist
ERROR:  table "qrtz_blob_triggers" does not exist
ERROR:  table "qrtz_triggers" does not exist
ERROR:  table "qrtz_job_details" does not exist
ERROR:  table "qrtz_calendars" does not exist
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_job_details_pkey" for table "qrtz_job_details"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_job_listeners_pkey" for table "qrtz_job_listeners"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_triggers_pkey" for table "qrtz_triggers"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_simple_triggers_pkey" for table "qrtz_simple_triggers"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_cron_triggers_pkey" for table "qrtz_cron_triggers"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_blob_triggers_pkey" for table "qrtz_blob_triggers"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_trigger_listeners_pkey" for table "qrtz_trigger_listeners"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_calendars_pkey" for table "qrtz_calendars"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_paused_trigger_grps_pkey" for table "qrtz_paused_trigger_grps"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_fired_triggers_pkey" for table "qrtz_fired_triggers"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_scheduler_state_pkey" for table "qrtz_scheduler_state"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "qrtz_locks_pkey" for table "qrtz_locks"
WARNING:  there is no transaction in progress
+ CERTS_HOME=/etc/candlepin/certs
+ CA_KEY_PASSWORD=/etc/candlepin/certs/candlepin-ca-password.txt
+ CA_KEY=/etc/candlepin/certs/candlepin-ca.key
+ CA_UPSTREAM_CERT=/etc/candlepin/certs/candlepin-upstream-ca.crt
+ CA_PUB_KEY=/etc/candlepin/certs/candlepin-ca-pub.key
+ CA_CERT=/etc/candlepin/certs/candlepin-ca.crt
+ KEYSTORE=/etc/candlepin/certs/keystore
+ '[' -f /root/.candlepinrc ']'
+ source /root/.candlepinrc
++ TC_HOME=/var/lib/tomcat6
+ rpm -q openssl
+ '[' 0 -ne 0 ']'
+ '[' '!' -d /etc/candlepin/certs ']'
+ HOSTNAME=jsefler-f12-candlepin.usersys.redhat.com
+ '[' -f /etc/candlepin/certs/candlepin-ca.key ']'
+ '[' -f /etc/candlepin/certs/candlepin-ca.crt ']'
+ '[' 1 '!=' 1 ']'
+ echo 'Creating CA private key password'
+ sudo su -c 'echo 10013 > /etc/candlepin/certs/candlepin-ca-password.txt'
+ echo 'Creating CA private key'
+ sudo openssl genrsa -out /etc/candlepin/certs/candlepin-ca.key -passout file:/etc/candlepin/certs/candlepin-ca-password.txt 1024
Generating RSA private key, 1024 bit long modulus
.........++++++
...............................++++++
e is 65537 (0x10001)
+ echo 'Creating CA public key'
+ sudo openssl rsa -pubout -in /etc/candlepin/certs/candlepin-ca.key -out /etc/candlepin/certs/candlepin-ca-pub.key
writing RSA key
+ echo 'Creating CA certificate'
+ sudo openssl req -new -x509 -days 365 -key /etc/candlepin/certs/candlepin-ca.key -out /etc/candlepin/certs/candlepin-ca.crt -subj /CN=jsefler-f12-candlepin.usersys.redhat.com/C=US/L=Raleigh/
+ sudo openssl pkcs12 -export -in /etc/candlepin/certs/candlepin-ca.crt -inkey /etc/candlepin/certs/candlepin-ca.key -out /etc/candlepin/certs/keystore -name tomcat -CAfile /etc/candlepin/certs/candlepin-ca.crt -caname root -chain -password pass:password
+ sudo cp /etc/candlepin/certs/candlepin-ca.crt /etc/candlepin/certs/candlepin-upstream-ca.crt
+ sudo chmod a+r /etc/candlepin/certs/keystore
product name: High availability (cluster suite) version: 1.0 arch: arch664847 type: SVC
product name: Load Balancing version: 1.0 arch: arch664847 type: SVC
product name: Shared Storage (GFS) version: 1.0 arch: arch664847 type: SVC
product name: Large File Support (XFS) version: 1.0 arch: arch664847 type: SVC
product name: Smart Management (RHN Management & Provisioning) version: 1.0 arch: arch664847 type: SVC
product name: Flexible Hypervisor(Physical Servers-Unlimited) version: 1.0 arch: arch664847 type: SVC
product name: Flexible Hypervisor(Premium Architectures-15-pack) version: 1.0 arch: arch664847 type: SVC
product name: RHEL for Physical Servers SVC version: 6.1 arch: arch664847 type: SVC
product name: RHEL for Workstations SVC version: 6.1 arch: arch664847 type: SVC
product name: RHEL for Physical Servers version: 1.0 arch: arch664847 type: MKT
product name: Basic RHEL Server version: 1.0 arch: arch664847 type: MKT
product name: RHEL Workstation version: 1.0 arch: arch664847 type: MKT
product name: RHEL Personal SVC version: 1.0 arch: arch664847 type: SVC
product name: RHEL Personal Bits version: ALL arch: arch664847 type: SYS
product name: RHEL Personal version: ALL arch: arch664847 type: MKT
product name: RHEL for Physical Servers ,2 Sockets, Standard Support with High
product name: RHEL for Physical Servers ,2 Sockets, L1-L3, Premium Support version: 6.1 arch: arch664847 type: MKT
product name: RHEL for Physical Servers ,4 Sockets, L1-L3, Premium Support version: 6.1 arch: arch664847 type: MKT
product name: RHEL for Physical Servers ,2 Sockets, L1-L3, Basic Support version: 6.1 arch: arch664847 type: MKT
product name: RHEL for Premium Architectures SVC version: 6.1 arch: arch664847 type: SVC
product name: Red Hat Linux 4.0 version: 4.0 arch: arch664847 type: SVC
product name: Red Hat Open Dos version: 5.1 arch: arch664847 type: SVC
product name: PRAD390 Awesome OS for IBM s390x systems version: 3.11 arch: arch664847 type: SVC
product name: PRAD390 Awesome OS for IBM s390x systems Product version: 3.11 arch: arch664847 type: MKT
product name: This MKT product makes RHEL 50% more better version: 3.11 arch: arch664847 type: MKT
product name: This MKT product makes mkt RHEL 50% more awesome version: 3.11 arch: arch664847 type: MKT
product name: This product makes mkt RHEL-server 50% more awesome version: 3.11 arch: arch664847 type: SVC
product name: This product makes RHEL-server 50% more RHEL! version: 3.11 arch: arch664847 type: SVC
product name: Beav product with a dependency version: 3.11 arch: arch664847 type: MKT
product name: RHEL for Premium Architectures version: 1.0 arch: arch664847 type: MKT
product name: RHEL for Premium Architectures, 16 socket, L1-L3, Standard support version: 6.1 arch: arch664847 type: MKT
product name: IPA Engineering Product version: 1.0 arch: arch664847 type: SVC
product name: IPA Client Pack (50) version: 1.0 arch: arch664847 type: MKT
product name: Smart Management Add On version: 1.0 arch: arch664847 type: MKT


3. Now on my client with an arch of x86 I autosubscribe and verify NO PRODUCTS GET bound....

[root@jsefler-onprem01 ca]# subscription-manager facts --list | grep arch
cpu.architecture: x86_64
[root@jsefler-onprem01 ca]# subscription-manager register --username testuser1 --password password --autosubscribe
1f3d0c31-cb5f-41f2-a514-3b274b22a212 jsefler-onprem01.usersys.redhat.com
[root@jsefler-onprem01 ca]# subscription-manager list --installed | grep Status
    Installed Product Status
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed       


4. Now I update the system facts with an arch of "arch664847"....

    
[root@jsefler-onprem01 ca]# echo '{"cpu.architecture": "arch664847"}' > /etc/rhsm/facts/test.facts
[root@jsefler-onprem01 ca]# subscription-manager facts --list | grep arch
cpu.architecture: arch664847
[root@jsefler-onprem01 ca]# subscription-manager facts --update
1f3d0c31-cb5f-41f2-a514-3b274b22a212
[root@jsefler-onprem01 ca]# subscription-manager unregister
System has been un-registered.


5. Now I autosubscribe and verify that at least SOME of my installed products get bound based on my arch...


[root@jsefler-onprem01 ca]# subscription-manager register --username testuser1 --password password --autosubscribe
5539f653-663b-4805-ae87-05c53de23f37 jsefler-onprem01.usersys.redhat.com
Subscribed to Products:
     RHEL Personal SVC(1)
     RHEL for Physical Servers SVC(37060)
     PRAD390 Awesome OS for IBM s390x systems(100000000000000)
     RHEL for Premium Architectures SVC(37062)
     Shared Storage (GFS)(37067)
     Red Hat Linux 4.0(1000000041)
     This product makes RHEL-server 50% more RHEL!(42001)
     Flexible Hypervisor(Premium Architectures-15-pack)(37)
     Smart Management (RHN Management & Provisioning)(37069)
     Flexible Hypervisor(Physical Servers-Unlimited)(38)
     RHEL for Workstations SVC(27060)
     This product makes mkt RHEL-server 50% more awesome(42000)
     Large File Support (XFS)(37068)
     High availability (cluster suite)(37065)
     Red Hat Open Dos(10000000000043)
     Load Balancing(37070)
     IPA Engineering Product(917571)
     RHEL Personal Bits(1144)
[root@jsefler-onprem01 ca]# subscription-manager list --installed | grep Status
    Installed Product Status
Status:             	Subscribed               
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Subscribed               
Status:             	Not Subscribed           
Status:             	Subscribed               
Status:             	Subscribed               
Status:             	Subscribed               
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Subscribed               
Status:             	Not Subscribed           
Status:             	Not Subscribed           
Status:             	Subscribed               
Status:             	Not Subscribed           
Status:             	Subscribed               
Status:             	Not Subscribed    


moving to VERIFIED