Bug 997935

Summary: Subscription-manager makes an unauthorized request after unregistering.
Product: Red Hat Enterprise Linux 6 Reporter: Alex Wood <awood>
Component: subscription-managerAssignee: Carter Kozak <ckozak>
Status: CLOSED ERRATA QA Contact: John Sefler <jsefler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.5CC: bkearney, ckozak, jesusr
Target Milestone: rc   
Target Release: 6.5   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
No description necessary
Story Points: ---
Clone Of:
: 1207403 (view as bug list) Environment:
Last Closed: 2013-11-21 21:27:48 UTC Type: Bug
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: 1207403    

Description Alex Wood 2013-08-16 14:58:57 UTC
Description of problem:
After unregistering, the subscription-manager CLI makes several additional requests back to Candlepin.  Because the consumer is unregistered at this point, these requests are unauthorized and cause Candlepin to return 401.  While subscription-manager handles these failed requests without any issue, the requests should never have been made in the first place.  Making these spurious requests is the root problem for bug #995292.

How reproducible: Always

Steps to Reproduce:
1. Register to a candlepin server.
2. Unregister.

Actual results:
Subscription-manager makes several additional requests to Candlepin after the call to DELETE /consumers/{uuid}.

The additional calls are a call to PUT /consumers/{uuid} and GET /consumers/{uuid}/compliance.

The calls are made as a result of calling the CliCommand._request_validity_check() method from UnRegisterCommand._do_command().

Expected results:
No additional calls are made after the call to DELETE.

Additional info:
You can monitor what calls are being made to Candlepin by adding the following line to /etc/candlepin/candlepin.conf:

log4j.logger.org.candlepin.servlet.filter=DEBUG

Comment 1 Carter Kozak 2013-08-16 20:57:18 UTC
commit 12db20afddae265e3353f1c3654b0fb1d1b55a7c
Author: ckozak <ckozak>
Date:   Fri Aug 16 11:23:21 2013 -0400

    997935: stop making requests after unregister

Comment 3 John Sefler 2013-09-16 16:21:59 UTC
Before verifying the fix, let's demonstrate the issue on version...
[root@jsefler-6 ~]# rpm -q subscription-manager
subscription-manager-1.9.3-1.el6.x86_64

register system with autosubscribe and then...
[root@jsefler-6 ~]# rm /var/log/rhsm/rhsm.log
rm: remove regular file `/var/log/rhsm/rhsm.log'? y
[root@jsefler-6 ~]# subscription-manager unregister
System has been unregistered.
[root@jsefler-6 ~]# grep -A1 "Making request" /var/log/rhsm/rhsm.log
2013-09-16 11:53:25,926 [DEBUG]  @connection.py:441 - Making request: GET /subscription/
2013-09-16 11:53:26,331 [DEBUG]  @connection.py:460 - Response status: 200
--
2013-09-16 11:53:26,339 [DEBUG]  @connection.py:441 - Making request: DELETE /subscription/consumers/71775a6e-40e0-4422-8db6-5bff074389ef
2013-09-16 11:53:27,045 [DEBUG]  @connection.py:460 - Response status: 204
--
2013-09-16 11:53:27,247 [DEBUG]  @connection.py:441 - Making request: GET /subscription/consumers/71775a6e-40e0-4422-8db6-5bff074389ef/compliance
2013-09-16 11:53:27,665 [DEBUG]  @connection.py:460 - Response status: 401
--
2013-09-16 11:53:27,678 [DEBUG]  @connection.py:441 - Making request: PUT /subscription/consumers/71775a6e-40e0-4422-8db6-5bff074389ef
2013-09-16 11:53:28,171 [DEBUG]  @connection.py:460 - Response status: 401
[root@jsefler-6 ~]# 

Notice the 401 responses logged above.  This is the issue.

Now after installing a fixed version of subscription-manager, let's verify...

[root@jsefler-6 ~]# rpm -q subscription-manager
subscription-manager-1.9.6-1.el6.x86_64

register system with autosubscribe and then...
[root@jsefler-6 ~]# rm /var/log/rhsm/rhsm.log
rm: remove regular file `/var/log/rhsm/rhsm.log'? y
[root@jsefler-6 ~]# subscription-manager unregister
System has been unregistered.
[root@jsefler-6 ~]# grep -A1 "Making request" /var/log/rhsm/rhsm.log
2013-09-16 12:14:30,386 [DEBUG]  @connection.py:441 - Making request: GET /subscription/
2013-09-16 12:14:30,804 [DEBUG]  @connection.py:460 - Response status: 200
--
2013-09-16 12:14:30,820 [DEBUG]  @connection.py:441 - Making request: DELETE /subscription/consumers/be70359f-2848-4208-8139-9348f8d96b9d
2013-09-16 12:14:31,555 [DEBUG]  @connection.py:460 - Response status: 204
[root@jsefler-6 ~]# 


VERIFIED: The GET and PUT requests that resulted in a 401 response after unregistering are no longer called.

Comment 4 errata-xmlrpc 2013-11-21 21:27:48 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-2013-1659.html