Bug 746262

Summary: Got Network error while subscribe quantity “+2”
Product: Red Hat Enterprise Linux 5 Reporter: spandey
Component: subscription-managerAssignee: Bryan Kearney <bkearney>
Status: CLOSED ERRATA QA Contact: IDM QE LIST <seceng-idm-qe-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 5.7CC: alikins, cduryee, jmolet, jsefler, kbanerje, skallesh, spandey, wpoteat
Target Milestone: beta   
Target Release: 5.8   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
No description necessary
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-21 06:42:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 715031    

Description spandey 2011-10-14 15:01:48 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:
3/3

Prerequisites:
Rhel6.2 client with following rpm 
subscription-manager-firstboot-0.96.15-1.el6.x86_64
.
subscription-manager-gnome-0.96.15-1.el6.x86_64.

subscription-manager-0.96.15-1.el6.x86_64
.

Candlepin : on-premises 

Steps to repro : 
Register client to candlepin.
Execute Following on client console to subscribe multi entitlement subscription with   quantity 

1)subscription-manager subscribe --pool ff80808132fbe4f80132fbe6336602a3 --quantity  2.0
2) subscription-manager subscribe --pool ff80808132fbe4f80132fbe6336602a3 --quantity +2

Expected Result :
At step 1 it should display 
		Quantity must be a positive integer
At Step 2 : 
Proper message should display for invalid argument .

Actual Result :
At step 1  
Error: Quantity must be a positive number 
		Note : Above “number” should change to “integer”.
At step 2 : 
 subscription-manager subscribe --pool ff80808132fbe4f80132fbe6336602a3 --quantity +2
Network error. Please check the connection details, or see /var/log/rhsm/rhsm.log for more information.


rhsm.log output 



2011-10-14 11:02:08,605 [INFO]  @connection.py:350 - Using certificate authentication: key = /etc/pki/consumer/key.pem, cert = /etc/pki/consumer/cert.pem, ca = /etc/rhsm/ca/, insecure = False
2011-10-14 11:02:08,605 [DEBUG]  @connection.py:188 - Loading CA PEM certificates from: /etc/rhsm/ca/
2011-10-14 11:02:08,606 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/candlepin-ca.pem'
2011-10-14 11:02:08,606 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/redhat-uep.pem'
2011-10-14 11:02:08,607 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/candlepin-stage.pem'
2011-10-14 11:02:08,608 [DEBUG]  @connection.py:209 - Making request: GET /candlepin/
2011-10-14 11:02:08,654 [DEBUG]  @connection.py:218 - Response status: 200
2011-10-14 11:02:08,656 [DEBUG]  @connection.py:379 - Server supports the following resources:
2011-10-14 11:02:08,657 [DEBUG]  @connection.py:380 - {'serials': '/serials', 'status': '/status', 'owners': '/owners', 'jobs': '/jobs', 'users': '/users', 'consumers': '/consumers', 'subscriptions': '/subscriptions', 'admin': '/admin', 'consumertypes': '/consumertypes', 'statistics/generate': '/statistics/generate', 'migrations': '/migrations', 'content': '/content', 'pools': '/pools', 'products': '/products', 'roles': '/roles', 'activation_keys': '/activation_keys', 'atom': '/atom', 'entitlements': '/entitlements', 'events': '/events', 'crl': '/crl', 'rules': '/rules'}
2011-10-14 11:02:08,658 [INFO]  @connection.py:362 - Connection Established: host: 10.65.193.159, port: 8443, handler: /candlepin
2011-10-14 11:02:08,659 [INFO]  @cache.py:154 - Checking current system info against cache: /var/lib/rhsm/facts/facts.json
2011-10-14 11:02:08,894 [DEBUG]  @cert_sorter.py:89 - Sorting product and entitlement cert status for: 2011-10-14 05:32:08.893876+00:00
2011-10-14 11:02:08,926 [DEBUG]  @cert_sorter.py:165 - Installed product IDs: ['100000000000006', '1000000000000023', '1144', '100000000000011', '100000000000010', '100000000000013', '100000000000012', '100000000000015', '27060', '69', '37090', '1', '37069', '37068', '37080', '37065', '37067', '37060', '37062', '100000000000060', '100000000000007', '100000000000004', '100000000000005', '100000000000002', '100000000000003', '100000000000000', '100000000000001', '100000000000020', '100000000000022', '100000000000009', '100000000000008', '917571', '37070']
2011-10-14 11:02:08,926 [DEBUG]  @cert_sorter.py:93 - valid entitled products: []
2011-10-14 11:02:08,926 [DEBUG]  @cert_sorter.py:94 - expired entitled products: []
2011-10-14 11:02:08,927 [DEBUG]  @cert_sorter.py:95 - partially entitled products: []
2011-10-14 11:02:08,927 [DEBUG]  @cert_sorter.py:96 - unentitled products: ['100000000000060', '1000000000000023', '1144', '100000000000011', '100000000000010', '100000000000013', '100000000000012', '100000000000015', '27060', '69', '917571', '1', '37069', '37068', '37080', '37065', '37067', '37060', '37062', '100000000000006', '100000000000007', '100000000000004', '100000000000005', '100000000000002', '100000000000003', '100000000000000', '100000000000001', '100000000000020', '100000000000022', '100000000000009', '100000000000008', '37090', '37070']
2011-10-14 11:02:08,927 [DEBUG]  @cert_sorter.py:97 - future products: []
2011-10-14 11:02:08,928 [INFO]  @cache.py:169 - No changes.
2011-10-14 11:02:08,928 [INFO]  @cache.py:209 - Server does not support packages, skipping profile upload.
2011-10-14 11:02:08,929 [DEBUG]  @connection.py:188 - Loading CA PEM certificates from: /etc/rhsm/ca/
2011-10-14 11:02:08,930 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/candlepin-ca.pem'
2011-10-14 11:02:08,930 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/redhat-uep.pem'
2011-10-14 11:02:08,931 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/candlepin-stage.pem'
2011-10-14 11:02:08,931 [DEBUG]  @connection.py:209 - Making request: POST /candlepin/consumers/355e6b04-e409-4bf8-ab44-cbd20af717c1/entitlements?pool=ff80808132fbe4f80132fbe6336602a3&quantity=+2
2011-10-14 11:02:08,981 [DEBUG]  @connection.py:218 - Response status: 400
2011-10-14 11:02:08,984 [ERROR]  @connection.py:230 - No JSON object could be decoded
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/rhsm/connection.py", line 228, in validateResponse
    parsed = json.loads(response['content'])
  File "/usr/lib64/python2.6/site-packages/simplejson/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.6/site-packages/simplejson/decoder.py", line 335, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.6/site-packages/simplejson/decoder.py", line 353, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
2011-10-14 11:02:08,988 [ERROR]  @connection.py:231 - Response: {'content': '<html><head><title>Apache Tomcat/6.0.26 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 400 - Unable to extract parameter from http request: javax.ws.rs.QueryParam(&quot;quantity&quot;) value is \' 2\' for public javax.ws.rs.core.Response org.fedoraproject.candlepin.resource.ConsumerResource.bind(java.lang.String,java.lang.String,java.lang.String[],java.lang.Integer,java.lang.String,java.lang.String,boolean,java.lang.String)</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Unable to extract parameter from http request: javax.ws.rs.QueryParam(&quot;quantity&quot;) value is \' 2\' for public javax.ws.rs.core.Response org.fedoraproject.candlepin.resource.ConsumerResource.bind(java.lang.String,java.lang.String,java.lang.String[],java.lang.Integer,java.lang.String,java.lang.String,boolean,java.lang.String)</u></p><p><b>description</b> <u>The request sent by the client was syntactically incorrect (Unable to extract parameter from http request: javax.ws.rs.QueryParam(&quot;quantity&quot;) value is \' 2\' for public javax.ws.rs.core.Response org.fedoraproject.candlepin.resource.ConsumerResource.bind(java.lang.String,java.lang.String,java.lang.String[],java.lang.Integer,java.lang.String,java.lang.String,boolean,java.lang.String)).</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.26</h3></body></html>', 'status': 400}
2011-10-14 11:02:08,988 [ERROR]  @managercli.py:65 - Unable to subscribe: 
2011-10-14 11:02:08,989 [ERROR]  @managercli.py:66 - 
Traceback (most recent call last):
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 832, in _do_command
    self.cp.bindByEntitlementPool(consumer_uuid, pool, self.options.quantity)
  File "/usr/lib/python2.6/site-packages/rhsm/connection.py", line 522, in bindByEntitlementPool
    return self.conn.request_post(method)
  File "/usr/lib/python2.6/site-packages/rhsm/connection.py", line 255, in request_post
    return self._request("POST", method, params)
  File "/usr/lib/python2.6/site-packages/rhsm/connection.py", line 219, in _request
    self.validateResponse(result)
  File "/usr/lib/python2.6/site-packages/rhsm/connection.py", line 236, in validateResponse
    raise NetworkException(response['status'])
NetworkException

Comment 2 Adrian Likins 2011-11-11 15:52:01 UTC
commit 705374a0124b40415b3ea3d360e2dfb6ce4ceea2
Author: Bryan Kearney <bkearney>
Date:   Thu Nov 3 16:28:51 2011 -0400

    746262: Quantity errors are reported as integers, and only ints are used for quantity subscriptions

Comment 5 J.C. Molet 2011-11-29 14:57:43 UTC
This looks like it accepts acceptable arguments.  Note that the fix does not throw an error with the "+2" arg, and it reads it as "2" (as I believe it should).

[root@jmolet-vm4 ~]# subscription-manager subscribe --pool=8a90f88f33ee92fb0133ee94222e04cf --quantity 2.0
Error: Quantity must be a positive integer.

[root@jmolet-vm4 ~]# subscription-manager subscribe --pool=8a90f88f33ee92fb0133ee94222e04cf --quantity +2
Successfully consumed a subscription from the pool with id 8a90f88f33ee92fb0133ee94222e04cf

[root@jmolet-vm4 ~]# subscription-manager subscribe --pool=8a90f88f33ee92fb0133ee94222e04cf --quantity "+2"
Successfully consumed a subscription from the pool with id 8a90f88f33ee92fb0133ee94222e04cf

[root@jmolet-vm4 ~]# subscription-manager unsubscribe --all
[root@jmolet-vm4 ~]# subscription-manager subscribe --pool=8a90f88f33ee92fb0133ee94222e04cf --quantity "a2"
Error: Quantity must be a positive integer.

[root@jmolet-vm4 ~]# subscription-manager subscribe --pool=8a90f88f33ee92fb0133ee94222e04cf --quantity "-2"
Error: Quantity must be a positive integer.

marking VERIFIED.
python-rhsm-0.98.3-1.git.2.74cd6bb.el5_7
subscription-manager-gnome-0.98.3-1.git.16.14460bc.el5_7
subscription-manager-firstboot-0.98.3-1.git.16.14460bc.el5_7
subscription-manager-0.98.3-1.git.16.14460bc.el5_7

Comment 6 William Poteat 2012-01-23 13:18:43 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
No description necessary

Comment 7 errata-xmlrpc 2012-02-21 06:42:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0154.html