Bug 1248833 - subscription-manager redeem is not reporting the response to stdout
subscription-manager redeem is not reporting the response to stdout
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: subscription-manager (Show other bugs)
7.2
Unspecified Unspecified
medium Severity low
: rc
: ---
Assigned To: Chris Snyder
J.C. Molet
: Regression
Depends On:
Blocks: 1263474
  Show dependency treegraph
 
Reported: 2015-07-30 19:00 EDT by John Sefler
Modified: 2015-11-19 06:50 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1263474 (view as bug list)
Environment:
Last Closed: 2015-11-19 06:50:15 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description John Sefler 2015-07-30 19:00:18 EDT
Description of problem:
After registering a system and making a call to redeem, I expect the server response to be fed back to the user.  It's not happening.

Version-Release number of selected component (if applicable):
[root@jsefler-os7 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 0.9.51.1-1
subscription management rules: 5.15
subscription-manager: 1.15.9-2.el7
python-rhsm: 1.15.4-2.el7


How reproducible:


Steps to Reproduce:
[root@jsefler-os7 ~]# echo '{"dmi.system.serial_number":"0000000"}' > /etc/rhsm/facts/automation_override.facts
[root@jsefler-os7 ~]# subscription-manager register --serverurl=subscription.rhn.stage.redhat.com --username=qa@redhat.com
Registering to: subscription.rhn.stage.redhat.com/subscription:443
Password: 
The system has been registered with ID: 42199c9d-c93a-417f-883a-9b21c6db23aa 
[root@jsefler-os7 ~]# subscription-manager redeem --email=qa@redhat.com
[root@jsefler-os7 ~]# 



Actual results:
no feedback

Expected results:
The system is unable to redeem the requested subscription: 0000000

Additional info:
[root@jsefler-os7 ~]# tail -f /var/log/rhsm/rhsm.log
2015-07-30 18:42:29,354 [DEBUG] subscription-manager:15948 @connection.py:500 - Making request: POST /subscription/subscriptions?consumer_uuid=42199c9d-c93a-417f-883a-9b21c6db23aa&email=qa@redhat.com&email_locale=en-us
2015-07-30 18:42:29,888 [DEBUG] subscription-manager:15948 @connection.py:528 - Response: status=202


^^ Notice that the POST appears successful.

Now let's use curl to see what was actually returned...

[root@jsefler-os7 ~]# curl -k -u qa@redhat.com:redhatqa --stderr /dev/null --request POST "https://subscription.rhn.stage.redhat.com:443/subscription/subscriptions?consumer_uuid=42199c9d-c93a-417f-883a-9b21c6db23aa&email=qa@redhat.com&email_locale=en-us" | python -m json/tool
{
    "displayMessage": "The system is unable to redeem the requested subscription: 0000000",
    "requestUuid": "d4aeb62e-af06-4073-ad4d-e97fa4b46380"
}

^^ Looks like the server is returning the correct displayMessage, but it is not being reported to the user.
Comment 2 Adrian Likins 2015-07-31 12:54:49 EDT
Looks like changes in python-rhsm that made 202 not raise an exception broke this.
Previously it expected to get a RestlibException in that case.
Comment 3 Adrian Likins 2015-07-31 12:57:03 EDT
Wonder if a 202 is really the right response in that case.
Comment 5 John Sefler 2015-08-25 15:55:20 EDT
The following failure occurs against an on-premise candlepin server...

[root@jsefler-7 ~]# subscription-manager register --username=testuser1 --password=password --org=admin --force --serverurl=jsefler-f22-candlepin.usersys.redhat.com:8443/candlepin
The system with UUID 6ae25316-8dd9-4ccf-8630-d4f94faf2cfb has been unregistered
Registering to: jsefler-f22-candlepin.usersys.redhat.com:8443/candlepin
The system has been registered with ID: 21cf0fbc-a3e2-4321-916d-4018df358755 
[root@jsefler-7 ~]# 
[root@jsefler-7 ~]# subscription-manager redeem --email=tester@redhat.com
[root@jsefler-7 ~]# 

BANG! no stdout feedback has been given.
Expected Stderr: "Standalone candlepin does not support redeeming a subscription for dmi.system.manufacturer:"



[root@jsefler-7 ~]# tail -f /var/log/rhsm/rhsm.log
2015-08-25 15:53:44,840 [DEBUG] subscription-manager:23637 @connection.py:500 - Making request: POST /candlepin/subscriptions?consumer_uuid=21cf0fbc-a3e2-4321-916d-4018df358755&email=tester@redhat.com&email_locale=en-us
2015-08-25 15:53:44,955 [DEBUG] subscription-manager:23637 @connection.py:528 - Response: status=204, requestUuid=d0a4b80e-75a9-4dfa-a469-fdfdb5b71ef8
Comment 6 Chris Snyder 2015-09-11 09:34:57 EDT
Should be in master as of commit: 3987d4341cf42623e57a92fdc20eed8b44f6526f


The issue was caused by a change to python-rhsm. In python-rhsm http response codes 202, and 204 were raising RestlibExceptions. They no longer do. As such subscription-manager was not checking the response for a displayMessage from candlepin.
Comment 7 Chris "Ceiu" Rog 2015-09-11 14:47:05 EDT
commit 0aff26c11d76cec1efaec7668ac11f939ed1e37b
Author: Christopher Snyder <csnyder@redhat.com>
Date:   Thu Sep 10 16:31:52 2015 -0400

    1248833: Ensure the displayMessage is displayed regardless of success or failure
Comment 9 J.C. Molet 2015-09-15 16:47:20 EDT
failure case in stage ( comment 1 )>>

# echo '{"dmi.system.serial_number":"0000000"}' > /etc/rhsm/facts/automation_override.facts

# subscription-manager register --serverurl=subscription.rhn.stage.redhat.com --username=qa@redhat.com
Registering to: subscription.rhn.stage.redhat.com:443/subscription
Password: 
The system has been registered with ID: 1505d4d2-b9b4-4b9b-ae95-3db43ba6527a 

# subscription-manager redeem --email=qa@redhat.com
The system is unable to redeem the requested subscription: 0000000

This appears to work.

------------------

The case in comment 5 does not seem to be any different.

# subscription-manager register --username=testuser1 --password=password --org=admin --force --serverurl=jsefler-f22-candlepin.usersys.redhat.com:8443/candlepin --insecure
Registering to: jsefler-f22-candlepin.usersys.redhat.com:8443/candlepin
The system has been registered with ID: f35a619b-bee5-4a9f-b41b-8606d858fc0b 
[root@jmolet-vm1 ~]# subscription-manager redeem --email=tester@redhat.com
[root@jmolet-vm1 ~]#
Comment 10 J.C. Molet 2015-09-15 16:51:45 EDT
comment 9 is in reference to build: 

# rpm -qa | egrep "python-rhsm|subscription-manager"
subscription-manager-1.15.9-10.el7.x86_64
python-rhsm-1.15.4-5.el7.x86_64
Comment 11 John Sefler 2015-09-15 17:39:15 EDT
Let's handle the failure case from comment 5 and comment 9 against a standalone candlepin server separately under candlepin bug 1263474.
Comment 12 J.C. Molet 2015-09-15 17:45:16 EDT
Marking VERIFIED for use case in comment 1, other issues will be handled in separate bug.
Comment 13 errata-xmlrpc 2015-11-19 06:50:15 EST
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.

https://rhn.redhat.com/errata/RHBA-2015-2122.html

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