Bug 798420

Summary: after restoring the consumer.old, list --avail gives "argument of type 'NoneType' is not iterable"
Product: Red Hat Enterprise Linux 6 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: Chris Duryee <cduryee>
Status: CLOSED ERRATA QA Contact: Entitlement Bugs <entitlement-bugs>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.3CC: cduryee, skallesh, spandey
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 13:06:24 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: 738066    

Description John Sefler 2012-02-28 20:24:30 UTC
Description of problem:
After a consumer is deleted on the server, a call to subscription-manager list --avail will report "Consumer UUID has been deleted".  Then after restoring the /etc/pki/consumer.old, the same call to subscription-manager list --avail throws "argument of type 'NoneType' is not iterable".

Version-Release number of selected component (if applicable):
[root@jsefler-r63-server ~]# rpm -q subscription-manager
subscription-manager-0.99.8-1.git.8.cc12bc5.el6.x86_64
[root@jsefler-f14-candlepin candlepin]# git show-ref | grep master
f8a4c7e8da230a0de0723f7ef185bbf5e3609397 refs/heads/master


How reproducible:


Steps to Reproduce:
[root@jsefler-r63-server ~]# subscription-manager register --username testuser1 --password password --org admin --force
The system has been registered with id: 8511a2a6-c2ec-4612-8186-af932a3b97cf 
[root@jsefler-r63-server ~]# subscription-manager identity
Current identity is: 8511a2a6-c2ec-4612-8186-af932a3b97cf
name: jsefler-r63-server.usersys.redhat.com
org name: Admin Owner
org id: 8a90f81435c17da90135c17e01240007
[root@jsefler-r63-server ~]# grep hostname /etc/rhsm/rhsm.conf
# Server hostname:
hostname=jsefler-f14-candlepin.usersys.redhat.com
proxy_hostname=
[root@jsefler-r63-server ~]# curl -k -u testuser1:password --request DELETE https://jsefler-f14-candlepin.usersys.redhat.com:8443/candlepin/consumers/8511a2a6-c2ec-4612-8186-af932a3b97cf
[root@jsefler-r63-server ~]# subscription-manager identity
Consumer 8511a2a6-c2ec-4612-8186-af932a3b97cf has been deleted
[root@jsefler-r63-server ~]# subscription-manager list --avail
Consumer 8511a2a6-c2ec-4612-8186-af932a3b97cf has been deleted
[root@jsefler-r63-server ~]# ls /etc/pki/
CA  consumer  entitlement  java  nssdb  product  rpm-gpg  rsyslog  tls
[root@jsefler-r63-server ~]# service rhsmcertd restart
Stopping rhsmcertd                                         [  OK  ]
Starting rhsmcertd 240 1440                                [  OK  ]
[root@jsefler-r63-server ~]# ls /etc/pki/
CA  consumer.old  entitlement  java  nssdb  product  rpm-gpg  rsyslog  tls
[root@jsefler-r63-server ~]# mv /etc/pki/consumer.old/ /etc/pki/consumer
[root@jsefler-r63-server ~]# subscription-manager identity
Consumer 8511a2a6-c2ec-4612-8186-af932a3b97cf has been deleted
[root@jsefler-r63-server ~]# subscription-manager list --avail
argument of type 'NoneType' is not iterable
[root@jsefler-r63-server ~]# 

^^^ expected that last call to subscription-manager list --avail to again report "Consumer 8511a2a6-c2ec-4612-8186-af932a3b97cf has been deleted"




[root@jsefler-r63-server ~]# tail -f /var/log/rhsm/rhsm.log

2012-02-28 15:05:19,290 [INFO]  @connection.py:384 - Using certificate authentication: key = /etc/pki/consumer/key.pem, cert = /etc/pki/consumer/cert.pem, ca = /etc/rhsm/ca/, insecure = False
2012-02-28 15:05:19,290 [INFO]  @connection.py:395 - Connection Built: host: jsefler-f14-candlepin.usersys.redhat.com, port: 8443, handler: /candlepin
2012-02-28 15:05:19,292 [INFO]  @cache.py:154 - Checking current system info against cache: /var/lib/rhsm/facts/facts.json
2012-02-28 15:05:19,293 [ERROR]  @cache.py:144 - Unable to read cache: /var/lib/rhsm/facts/facts.json
2012-02-28 15:05:19,787 [DEBUG]  @cert_sorter.py:106 - Sorting product and entitlement cert status for: 2012-02-28 20:05:19.787068+00:00
2012-02-28 15:05:19,833 [DEBUG]  @cert_sorter.py:159 - Installed product IDs: ['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']
2012-02-28 15:05:19,834 [DEBUG]  @cert_sorter.py:112 - valid entitled products: []
2012-02-28 15:05:19,834 [DEBUG]  @cert_sorter.py:113 - expired entitled products: []
2012-02-28 15:05:19,834 [DEBUG]  @cert_sorter.py:114 - partially entitled products: []
2012-02-28 15:05:19,834 [DEBUG]  @cert_sorter.py:115 - unentitled products: ['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']
2012-02-28 15:05:19,835 [DEBUG]  @cert_sorter.py:116 - future products: []
2012-02-28 15:05:19,835 [DEBUG]  @cert_sorter.py:117 - partial stacks: []
2012-02-28 15:05:19,835 [DEBUG]  @cert_sorter.py:118 - valid stacks: []
2012-02-28 15:05:19,836 [ERROR]  @managercli.py:94 - exception caught in subscription-manager
2012-02-28 15:05:19,836 [ERROR]  @managercli.py:95 - argument of type 'NoneType' is not iterable
Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 79, in <module>
    sys.exit(abs(main() or 0))
  File "/usr/sbin/subscription-manager", line 70, in main
    return managercli.CLI().main()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 1603, in main
    return cmd.main()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 265, in main
    return_code = self._do_command()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 1435, in _do_command
    self.facts, self.options.all, on_date)
  File "/usr/share/rhsm/subscription_manager/managerlib.py", line 323, in getAvailableEntitlements
    dlist = list_pools(cpserver, consumer_uuid, facts, get_all, active_on)
  File "/usr/share/rhsm/subscription_manager/managerlib.py", line 296, in list_pools
    facts.update_check(uep, consumer_uuid)
  File "/usr/share/rhsm/subscription_manager/cache.py", line 155, in update_check
    if self.has_changed() or force:
  File "/usr/share/rhsm/subscription_manager/facts.py", line 72, in has_changed
    if key not in cached_facts:
TypeError: argument of type 'NoneType' is not iterable




I suspect the reason this happens is because the rhsmcertd restart causes the deleted system.uuid to be removed from the system facts (which I believe is the right thing to do).  Then the manual restoring of /etc/pki/consumer.old to /etc/pki/consumer creates a situation where the consumer cert no longer matches the system facts.  This is demonstrated below.


[root@jsefler-r63-server ~]# subscription-manager facts --list | grep system.uuid
dmi.system.uuid: a2e71856-6778-7975-772a-21750aa3eeb0
system.uuid: 7ff4cf62-ce2f-4911-a180-60ba9369d5c1
[root@jsefler-r63-server ~]# subscription-manager list --avail
Consumer 7ff4cf62-ce2f-4911-a180-60ba9369d5c1 has been deleted
[root@jsefler-r63-server ~]# service rhsmcertd restart
Stopping rhsmcertd                                         [  OK  ]
Starting rhsmcertd 240 1440                                [  OK  ]
[root@jsefler-r63-server ~]# subscription-manager facts --list | grep system.uuid
dmi.system.uuid: a2e71856-6778-7975-772a-21750aa3eeb0
[root@jsefler-r63-server ~]# mv /etc/pki/consumer.old/ /etc/pki/consumer
[root@jsefler-r63-server ~]# subscription-manager list --avail
argument of type 'NoneType' is not iterable
[root@jsefler-r63-server ~]# 



Overall I think this is a really low priority bug and probably an invalid test scenario.

Comment 1 Chris Duryee 2012-03-26 16:27:42 UTC
This appears to have been fixed as part of bz 797243. I commented out Adrian's fix, and the bug reappears.

1b5abbd9 master 0.99.9+

Comment 3 Shwetha Kallesh 2012-03-29 10:02:55 UTC
Verified..

RPM used:
[root@skallesh entitlement]# rpm -qa | grep subscription-manager
subscription-manager-debuginfo-0.99.12-1.el6.x86_64
subscription-manager-firstboot-0.99.12-1.git.5.5f0e228.el6.x86_64
subscription-manager-migration-data-1.12.1.2-1.git.0.9e244c8.el6.noarch
subscription-manager-gnome-0.99.12-1.git.5.5f0e228.el6.x86_64
subscription-manager-migration-0.99.12-1.git.5.5f0e228.el6.x86_64
subscription-manager-0.99.12-1.git.5.5f0e228.el6.x86_64

Steps:

[root@skallesh pki]# curl -k -u admin:admin --request DELETE "https://10.65.201.177:8443/candlepin/consumers/74f397df-6651-412a-ba06-098663daef9f"
[root@skallesh pki]# service rhsmcertd restart
Stopping rhsmcertd                                         [  OK  ]
Starting rhsmcertd 240 1440                                [  OK  ]
[root@skallesh pki]# ls /etc/pki/
CA  consumer.old  java  nssdb  product  rpm-gpg  rsyslog  tls  tmp
[root@skallesh pki]# mv /etc/pki/consumer.old/ /etc/pki/consumer
[root@skallesh pki]# subscription-manager identity
Consumer 74f397df-6651-412a-ba06-098663daef9f has been deleted
[root@skallesh pki]# subscription-manager list --avail
Consumer 74f397df-6651-412a-ba06-098663daef9f has been deleted

Comment 5 errata-xmlrpc 2012-06-20 13:06:24 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-0804.html