Bug 733525

Summary: [Errno 2] No such file or directory: '/etc/pki/entitlement'
Product: Red Hat Enterprise Linux 6 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: Michael Stead <mstead>
Status: CLOSED ERRATA QA Contact: John Sefler <jsefler>
Severity: urgent Docs Contact:
Priority: high    
Version: 6.2CC: bkearney, khong, mstead, skallesh, spandey
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
No description necessary
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 17:23:41 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: 682238    

Description John Sefler 2011-08-25 21:54:18 UTC
Description of problem:
Re-registering a client using --force is throwing a traceback
Note: This is a regression.  It has worked for a long time.


Version-Release number of selected component (if applicable):
[root@jsefler-onprem-62workstation ~]# rpm -q subscription-manager
subscription-manager-0.96.7-1.git.1.c513aca.el6.x86_64


How reproducible:


Steps to Reproduce:
[root@jsefler-onprem-62workstation ~]# subscription-manager register --username=testuser1 --password=password --org=admin
The system has been registered with id: d6649009-c6e0-44bd-be27-7d06ee92952d 
[root@jsefler-onprem-62workstation ~]# subscription-manager register --username=testuser1 --password=password --org=admin --force
The system with UUID d6649009-c6e0-44bd-be27-7d06ee92952d has been unregistered
[Errno 2] No such file or directory: '/etc/pki/entitlement'
[root@jsefler-onprem-62workstation ~]# echo $?
255

^^^ DID NOT EXPECT THE ERRNO AND THE 255 EXIT CODE


# tail -f /var/log/rhsm/rhsm.log

Additional info:2011-08-25 17:38:22,863 [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-08-25 17:38:22,864 [DEBUG]  @connection.py:188 - Loading CA PEM certificates from: /etc/rhsm/ca/
2011-08-25 17:38:22,864 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/candlepin-stage.pem'
2011-08-25 17:38:22,864 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/redhat-uep.pem'
2011-08-25 17:38:22,865 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/fakamai-cp1.pem'
2011-08-25 17:38:22,865 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/jsefler-onprem-62candlepin.pem'
2011-08-25 17:38:22,866 [DEBUG]  @connection.py:209 - Making request: GET /candlepin/
2011-08-25 17:38:22,950 [DEBUG]  @connection.py:218 - Response status: 200
2011-08-25 17:38:22,952 [DEBUG]  @connection.py:379 - Server supports the following resources:
2011-08-25 17:38:22,952 [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', 'content': '/content', 'pools': '/pools', 'products': '/products', 'activation_keys': '/activation_keys', 'atom': '/atom', 'entitlements': '/entitlements', 'events': '/events', 'crl': '/crl', 'rules': '/rules'}
2011-08-25 17:38:22,952 [INFO]  @connection.py:362 - Connection Established: host: jsefler-onprem-62candlepin.usersys.redhat.com, port: 8443, handler: /candlepin
2011-08-25 17:38:23,027 [DEBUG]  @connection.py:188 - Loading CA PEM certificates from: /etc/rhsm/ca/
2011-08-25 17:38:23,027 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/candlepin-stage.pem'
2011-08-25 17:38:23,027 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/redhat-uep.pem'
2011-08-25 17:38:23,028 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/fakamai-cp1.pem'
2011-08-25 17:38:23,028 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/jsefler-onprem-62candlepin.pem'
2011-08-25 17:38:23,029 [DEBUG]  @connection.py:209 - Making request: DELETE /candlepin/consumers/cf271a7c-51b4-4981-9768-2921c58c1110
2011-08-25 17:38:23,253 [DEBUG]  @connection.py:218 - Response status: 204
2011-08-25 17:38:23,256 [INFO]  @managerlib.py:846 - Successfully un-registered.
2011-08-25 17:38:23,259 [INFO]  @cache.py:106 - Deleting cache: /var/lib/rhsm/facts/facts.json
2011-08-25 17:38:23,260 [INFO]  @cache.py:106 - Deleting cache: /var/lib/rhsm/cache/installed_products.json
2011-08-25 17:38:23,261 [INFO]  @managercli.py:555 - --force specified, un-registered old consumer: cf271a7c-51b4-4981-9768-2921c58c1110
2011-08-25 17:38:23,262 [INFO]  @connection.py:339 - Using basic authentication as: testuser1
2011-08-25 17:38:23,263 [DEBUG]  @connection.py:188 - Loading CA PEM certificates from: /etc/rhsm/ca/
2011-08-25 17:38:23,263 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/candlepin-stage.pem'
2011-08-25 17:38:23,264 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/redhat-uep.pem'
2011-08-25 17:38:23,265 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/fakamai-cp1.pem'
2011-08-25 17:38:23,265 [DEBUG]  @connection.py:171 - Loading CA certificate: '/etc/rhsm/ca/jsefler-onprem-62candlepin.pem'
2011-08-25 17:38:23,266 [DEBUG]  @connection.py:209 - Making request: GET /candlepin/
2011-08-25 17:38:23,315 [DEBUG]  @connection.py:218 - Response status: 200
2011-08-25 17:38:23,318 [DEBUG]  @connection.py:379 - Server supports the following resources:
2011-08-25 17:38:23,319 [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', 'content': '/content', 'pools': '/pools', 'products': '/products', 'activation_keys': '/activation_keys', 'atom': '/atom', 'entitlements': '/entitlements', 'events': '/events', 'crl': '/crl', 'rules': '/rules'}
2011-08-25 17:38:23,321 [INFO]  @connection.py:362 - Connection Established: host: jsefler-onprem-62candlepin.usersys.redhat.com, port: 8443, handler: /candlepin
2011-08-25 17:38:23,507 [DEBUG]  @cert_sorter.py:73 - Sorting product and entitlement cert status for: 2011-08-25 17:38:23.507252
2011-08-25 17:38:23,566 [DEBUG]  @cert_sorter.py:97 - Installed product IDs: ['100000000000060', '1000000000000023', '1144', '100000000000011', '100000000000010', '100000000000013', '100000000000012', '100000000000015', '27060', '917571', '1', '37069', '37068', '37080', '37065', '37067', '37060', '37062', '100000000000006', '100000000000007', '100000000000004', '100000000000005', '100000000000002', '100000000000003', '100000000000000', '100000000000001', '100000000000020', '100000000000022', '100000000000009', '100000000000008', '37090', '37070']
2011-08-25 17:38:23,568 [ERROR]  @managercli.py:63 - Error during registration: [Errno 2] No such file or directory: '/etc/pki/entitlement'
2011-08-25 17:38:23,568 [ERROR]  @managercli.py:64 - [Errno 2] No such file or directory: '/etc/pki/entitlement'
Traceback (most recent call last):
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 588, in _do_command
    type=self.options.consumertype, facts=self.facts.get_facts(),
  File "/usr/share/rhsm/subscription_manager/facts.py", line 93, in get_facts
    self.facts = self._load_custom_facts()
  File "/usr/share/rhsm/subscription_manager/facts.py", line 125, in _load_custom_facts
    facts_dict=facts)
  File "/usr/share/rhsm/subscription_manager/cert_sorter.py", line 77, in __init__
    self._scan_entitlement_certs()
  File "/usr/share/rhsm/subscription_manager/cert_sorter.py", line 100, in _scan_entitlement_certs
    ent_certs = self.entitlement_dir.list()
  File "/usr/share/rhsm/subscription_manager/certdirectory.py", line 105, in list
    for p, fn in Directory.list(self):
  File "/usr/share/rhsm/subscription_manager/certdirectory.py", line 49, in list
    for p, fn in self.listAll():
  File "/usr/share/rhsm/subscription_manager/certdirectory.py", line 42, in listAll
    for fn in os.listdir(self.path):
OSError: [Errno 2] No such file or directory: '/etc/pki/entitlement'

Comment 2 Keqin Hong 2011-08-26 10:16:07 UTC
The problem can also be reproduced by register then unregister through GUI.

subscription-manager-0.96.7-1.el6.x86_64
subscription-manager-gnome-0.96.7-1.el6.x86_64
python-rhsm-0.96.10-1.el6.noarch

Comment 3 Michael Stead 2011-08-29 13:20:20 UTC
Fixed in master branch: ce5c072361a558f9706742de4a91f282ba3c0e34

Added checks to make sure that the directory exists before listing files.

Comment 4 Michael Stead 2011-08-29 13:21:06 UTC
*** Bug 733658 has been marked as a duplicate of this bug. ***

Comment 7 Shwetha Kallesh 2011-09-02 07:50:04 UTC
Moving the bug to verified

RPM used:

rpm -q subscription-manager
subscription-manager-0.96.8-1.git.4.161be60.el6.x86_64

Steps to reproduce :
subscription-manager register --username=testuser1 --password=password --org=admin --force
The system with UUID 4f4cd84f-3bdd-4e59-8990-fd71ee4958d4 has been unregistered
The system has been registered with id: cef368f2-8ab7-40c5-ac7f-a059206ca03b

Comment 8 Bryan Kearney 2011-11-14 17:32:10 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 9 errata-xmlrpc 2011-12-06 17:23:41 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-2011-1695.html