Bug 838187

Summary: some subscription-manager modules fail after consumer has been deleted server side
Product: Red Hat Enterprise Linux 5 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: Adrian Likins <alikins>
Status: CLOSED ERRATA QA Contact: Entitlement Bugs <entitlement-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 5.9CC: alikins, awood, bgollahe, bkearney
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
No documentation necessary.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-08 03:56:44 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: 771748    

Description John Sefler 2012-07-06 23:56:22 UTC
Description of problem:
In the scenario where a consumer is deleted on the server-side (for example using a tool like rhsm-web), the client should recognize the server's response when the consumer has been deleted and the local consumer is no longer valid.

In the recreate steps below some of the module commands (list --avail, subscribe --pool, facts --update) have regressed with they used to say "Consumer HASH has been deleted".

Version-Release number of selected component (if applicable):
[root@jsefler-59server ~]# rpm -q subscription-manager python-rhsm
subscription-manager-1.0.8-1.git.9.9d4d24c.el5
python-rhsm-1.0.3-1.git.0.583d26c.el5


How reproducible:


Steps to Reproduce:
[root@jsefler-59server ~]# subscription-manager config --server.hostname jsefler-f14-candlepin.usersys.redhat.com --server.prefix /candlepin --server.port 8443 --server.insecure 1

[root@jsefler-59server ~]# subscription-manager register --username testuser1 --org adminPassword: 
The system has been registered with id: 5382f8f6-940a-42e4-a5da-b58485665206 

[root@jsefler-59server ~]# subscription-manager list --avail | grep "Pool Id" | tail -1
Pool Id:              	8a90f8753859805a013859816a090480

[root@jsefler-59server ~]# curl --stderr /dev/null --insecure --user testuser1:password --request DELETE https://jsefler-f14-candlepin.usersys.redhat.com:8443/candlepin/consumers/5382f8f6-940a-42e4-a5da-b58485665206

[root@jsefler-59server ~]# subscription-manager identity
Consumer 5382f8f6-940a-42e4-a5da-b58485665206 has been deleted

[root@jsefler-59server ~]# subscription-manager list --avail
Error updating system data, see /var/log/rhsm/rhsm.log for more details.
^^^^^ REGRESSION, SHOULD BE Consumer HASH has been deleted

[root@jsefler-59server ~]# subscription-manager refresh
Consumer 5382f8f6-940a-42e4-a5da-b58485665206 has been deleted

[root@jsefler-59server ~]# subscription-manager subscribe --pool 8a90f8753859805a013859816a090480
Error updating system data, see /var/log/rhsm/rhsm.log for more details.
^^^^^ REGRESSION, SHOULD BE Consumer HASH has been deleted

[root@jsefler-59server ~]# subscription-manager unsubscribe --all
Consumer 5382f8f6-940a-42e4-a5da-b58485665206 has been deleted

[root@jsefler-59server ~]# subscription-manager service-level
Consumer 5382f8f6-940a-42e4-a5da-b58485665206 has been deleted

[root@jsefler-59server ~]# subscription-manager facts --update
Error updating system data, see /var/log/rhsm/rhsm.log for more details.
^^^^^ REGRESSION, SHOULD BE Consumer HASH has been deleted

[root@jsefler-59server ~]# subscription-manager unregister
Consumer 5382f8f6-940a-42e4-a5da-b58485665206 has been deleted




Actual results:
Some results above are "Error updating system data, see /var/log/rhsm/rhsm.log for more details."

Expected results:
Consumer 5382f8f6-940a-42e4-a5da-b58485665206 has been deleted



Additional info:

[root@jsefler-59server ~]# tail -f /var/log/rhsm/rhsm.log
2012-07-06 19:45:09,914 [INFO]  @connection.py:483 - Using certificate authentication: key = /tmp/consumer/key.pem, cert = /tmp/consumer/cert.pem, ca = /etc/rhsm/ca/, insecure = True
2012-07-06 19:45:09,914 [INFO]  @connection.py:496 - Connection Built: host: jsefler-f14-candlepin.usersys.redhat.com, port: 8443, handler: /candlepin
2012-07-06 19:45:09,914 [DEBUG]  @profile.py:95 - Loading current RPM profile.
2012-07-06 19:45:10,098 [DEBUG]  @connection.py:329 - Making request: GET /candlepin/
2012-07-06 19:45:10,233 [DEBUG]  @connection.py:342 - Response status: 410
2012-07-06 19:45:10,316 [DEBUG]  @managercli.py:396 - Versions: {'subscription manager': '1.0.8-1.git.9.9d4d24c.el5', 'server-type': 'subscription management service', 'python-rhsm': '1.0.3-1.git.0.583d26c.el5', 'candlepin': 'Unknown'} 
2012-07-06 19:45:10,319 [INFO]  @cache.py:160 - Checking current system info against cache: /var/lib/rhsm/facts/facts.json
2012-07-06 19:45:10,457 [DEBUG]  @cert_sorter.py:106 - Sorting product and entitlement cert status for: 2012-07-06 23:45:10.457638+00:00
2012-07-06 19:45:10,511 [DEBUG]  @cert_sorter.py:160 - Installed product IDs: ['100000000000060', '1000000000000023', '1144', '100000000000011', '100000000000010', '100000000000013', '100000000000012', '100000000000015', '99000', '27060', '69', '917571', '1', '37069', '37068', '37080', '37065', '37067', '37060', '37062', '100000000000006', '100000000000007', '100000000000004', '100000000000005', '100000000000002', '100000000000003', '100000000000000', '100000000000001', '100000000000020', '100000000000008', '100000000000009', '100000000000022', '88888', '37090', '37070']
2012-07-06 19:45:10,512 [DEBUG]  @cert_sorter.py:113 - valid entitled products: []
2012-07-06 19:45:10,512 [DEBUG]  @cert_sorter.py:114 - expired entitled products: []
2012-07-06 19:45:10,512 [DEBUG]  @cert_sorter.py:115 - partially entitled products: []
2012-07-06 19:45:10,512 [DEBUG]  @cert_sorter.py:116 - unentitled products: ['100000000000006', '1000000000000023', '1144', '100000000000011', '100000000000010', '100000000000013', '100000000000012', '100000000000015', '99000', '27060', '69', '37090', '1', '37069', '37068', '37080', '37065', '37067', '37060', '37062', '100000000000060', '100000000000007', '100000000000004', '100000000000005', '100000000000002', '100000000000003', '100000000000000', '100000000000001', '100000000000020', '100000000000008', '100000000000009', '100000000000022', '88888', '917571', '37070']
2012-07-06 19:45:10,512 [DEBUG]  @cert_sorter.py:117 - future products: []
2012-07-06 19:45:10,513 [DEBUG]  @cert_sorter.py:118 - partial stacks: []
2012-07-06 19:45:10,513 [DEBUG]  @cert_sorter.py:119 - valid stacks: []
2012-07-06 19:45:10,514 [INFO]  @cache.py:162 - System data has changed, updating server.
2012-07-06 19:45:10,514 [DEBUG]  @facts.py:139 - Updating facts on server
2012-07-06 19:45:10,516 [DEBUG]  @connection.py:329 - Making request: PUT /candlepin/consumers/5382f8f6-940a-42e4-a5da-b58485665206
2012-07-06 19:45:10,582 [DEBUG]  @connection.py:342 - Response status: 410
2012-07-06 19:45:10,583 [ERROR]  @cache.py:170 - Error updating system data
2012-07-06 19:45:10,584 [ERROR]  @cache.py:171 - Consumer 5382f8f6-940a-42e4-a5da-b58485665206 has been deleted
Traceback (most recent call last):
  File "/usr/share/rhsm/subscription_manager/cache.py", line 164, in update_check
    self._update_server(uep, consumer_uuid)
  File "/usr/share/rhsm/subscription_manager/facts.py", line 140, in _update_server
    uep.updateConsumer(consumer_uuid, facts=self.get_facts())
  File "/usr/lib/python2.4/site-packages/rhsm/connection.py", line 611, in updateConsumer
    ret = self.conn.request_put(method, params)
  File "/usr/lib/python2.4/site-packages/rhsm/connection.py", line 394, in request_put
    return self._request("PUT", method, params)
  File "/usr/lib/python2.4/site-packages/rhsm/connection.py", line 347, in _request
    self.validateResponse(result)
  File "/usr/lib/python2.4/site-packages/rhsm/connection.py", line 369, in validateResponse
    parsed['displayMessage'], parsed['deletedId'])
GoneException: Consumer 5382f8f6-940a-42e4-a5da-b58485665206 has been deleted
2012-07-06 19:45:10,590 [ERROR]  @managercli.py:114 - exception caught in subscription-manager
2012-07-06 19:45:10,590 [ERROR]  @managercli.py:115 - Error updating system data, see /var/log/rhsm/rhsm.log for more details.
Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 78, in ?
    sys.exit(abs(main() or 0))
  File "/usr/sbin/subscription-manager", line 69, in main
    return managercli.CLI().main()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 1963, in main
    return cmd.main()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 400, in main
    return_code = self._do_command()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 1729, in _do_command
    self.facts, self.options.all, on_date)
  File "/usr/share/rhsm/subscription_manager/managerlib.py", line 325, in getAvailableEntitlements
    dlist = list_pools(cpserver, consumer_uuid, facts, get_all, active_on)
  File "/usr/share/rhsm/subscription_manager/managerlib.py", line 297, in list_pools
    facts.update_check(uep, consumer_uuid)
  File "/usr/share/rhsm/subscription_manager/cache.py", line 172, in update_check
    raise Exception(_("Error updating system data, see /var/log/rhsm/rhsm.log "
Exception: Error updating system data, see /var/log/rhsm/rhsm.log for more details.

[root@jsefler-59server ~]#

Comment 2 Adrian Likins 2012-08-02 16:39:42 UTC
This sounds like the same issue as https://bugzilla.redhat.com/show_bug.cgi?id=838113 (#838113) 

Does the following commit fix it?


commit 441f13b5d656f5caf3d93609444c280fd82ec7d8
Author: Adrian Likins <alikins>
Date:   Wed Aug 1 15:23:01 2012 -0400

    838113: 'unregister' was not cleaning up repos
    
    After unregistering, we were running IdentityCertLib update
    actions, which assumed consumer cert existed, and were
    raising exceptions. certmgt.update was not handling
    exceptions there well, and raised them up into
    the UnRegister.do_command, where it was ignored.
    This prevented the rest of the update methods from
    running, which included repolib, so repo's were
    not being cleaned up.
    
    Try to handle exceptions in the update actions
    better (and log them). Also make IdentityCertLib.update
    not fail on unregistered systems.

Comment 4 John Sefler 2012-10-11 15:37:19 UTC
Verifying Version...
[root@jsefler-rhel59 ~]# rpm -q subscription-manager
subscription-manager-1.0.22-1.el5

[root@jsefler-rhel59 ~]# subscription-manager identity
Consumer a186fd2b-28ab-49c3-bb15-b2e086a05103 has been deleted
[root@jsefler-rhel59 ~]# subscription-manager list --avail
Consumer a186fd2b-28ab-49c3-bb15-b2e086a05103 has been deleted
[root@jsefler-rhel59 ~]# subscription-manager refresh
Consumer a186fd2b-28ab-49c3-bb15-b2e086a05103 has been deleted
[root@jsefler-rhel59 ~]# subscription-manager subscribe --pool 8a90f8753859805a013859816a090480
Consumer a186fd2b-28ab-49c3-bb15-b2e086a05103 has been deleted
[root@jsefler-rhel59 ~]# subscription-manager unsubscribe --all
Consumer a186fd2b-28ab-49c3-bb15-b2e086a05103 has been deleted
[root@jsefler-rhel59 ~]# subscription-manager service-level
Consumer a186fd2b-28ab-49c3-bb15-b2e086a05103 has been deleted
[root@jsefler-rhel59 ~]# subscription-manager facts --update
Error updating system data on the server, see /var/log/rhsm/rhsm.log for more details.      <=============  SEE BUG 798788
[root@jsefler-rhel59 ~]# subscription-manager unregister
Consumer a186fd2b-28ab-49c3-bb15-b2e086a05103 has been deleted

Moving to VERIFIED

Comment 6 errata-xmlrpc 2013-01-08 03:56:44 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-0033.html