Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1284120

Summary: Traceback "KeyError: 'rules-version'" is thrown when calling subscription-manager version
Product: Red Hat Enterprise Linux 6 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED ERRATA QA Contact: John Sefler <jsefler>
Severity: high Docs Contact:
Priority: high    
Version: 6.8CC: alikins, bcourt, csnyder, tlavigne
Target Milestone: rcKeywords: Regression, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-10 20:38:14 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:

Description John Sefler 2015-11-20 22:22:31 UTC
Description of problem:


Version-Release number of selected component (if applicable):
[root@jsefler-6 ~]# rpm -q subscription-manager python-rhsm
subscription-manager-1.16.4-1.git.28.d68b76a.el6.x86_64
python-rhsm-1.16.2-1.git.3.645f806.el6.x86_64


How reproducible:


Steps to Reproduce:
[root@jsefler-6 ~]# subscription-manager version
server type: Unknown
subscription management server: Unknown
'rules-version'



Actual results:
 above

Expected results:
 the version of the configured candlepin server as well as the installed rhsm packages

Additional info:
[root@jsefler-6 ~]# tail -f /var/log/rhsm/rhsm.log
2015-11-20 17:14:40,558 [DEBUG] subscription-manager:7032 @connection.py:530 - Making request: GET /candlepin/status
2015-11-20 17:14:40,627 [DEBUG] subscription-manager:7032 @connection.py:562 - Response: status=200, requestUuid=241e5da3-f683-4cac-a244-4f58c9b0d578
2015-11-20 17:14:40,634 [INFO] subscription-manager:7032 @managercli.py:368 - Server Versions: {'rules-version': '5.19', 'candlepin': '2.0.9-1', 'server-type': 'This system is currently not registered.'}
2015-11-20 17:14:40,684 [ERROR] subscription-manager:7032 @managercli.py:165 - exception caught in subscription-manager
2015-11-20 17:14:40,685 [ERROR] subscription-manager:7032 @managercli.py:166 - 'rules-version'
Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 86, in <module>
    sys.exit(abs(main() or 0))
  File "/usr/sbin/subscription-manager", line 77, in main
    return managercli.ManagerCLI().main()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 2684, in main
    return CLI.main(self)
  File "/usr/share/rhsm/subscription_manager/cli.py", line 160, in main
    return cmd.main()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 500, in main
    return_code = self._do_command()
  File "/usr/share/rhsm/subscription_manager/managercli.py", line 2614, in _do_command
    print (_("subscription management rules: %s") % self.server_versions["rules-version"])
KeyError: 'rules-version'

Comment 2 Adrian Likins 2015-11-30 21:51:29 UTC
Looks like version command is expecting the self.server_versions dict to be setup, but the request hasn't happened yet.

With some extra logging and threadName in log format:

2015-11-30 16:50:27,980 [INFO] subscription-manager:31788:MainThread @connection.py:788 - Connection built: host=grimlock.usersys.redhat.com port=8443 handler=/candlepin auth=none
2015-11-30 16:50:27,993 [DEBUG] subscription-manager:31788:MainThread @managercli.py:2613 - self.server_versions {'candlepin': 'Unknown', 'server-type': 'Unknown'}
2015-11-30 16:50:28,018 [DEBUG] subscription-manager:31788:ServerVersionThread @connection.py:482 - Loaded CA certificates from /etc/rhsm/ca/: candlepin-grimlock.pem, redhat-uep.pem, bundle.pem, ca_bundle.pem
2015-11-30 16:50:28,019 [DEBUG] subscription-manager:31788:ServerVersionThread @connection.py:530 - Making request: GET /candlepin/
2015-11-30 16:50:28,042 [DEBUG] subscription-manager:31788:ServerVersionThread @connection.py:562 - Response: status=200, requestUuid=31356c8a-97c9-44c5-88be-bf9b57dc8dfb
2015-11-30 16:50:28,043 [DEBUG] subscription-manager:31788:ServerVersionThread @connection.py:805 - Server supports the following resources: {'': '/', 'guestids': '/consumers/{consumer_uuid}/guestids', 'cdn': '/cdn', 'content_overrides': '/consumers/{consumer_uuid}/content_overrides', 'hypervisors': '/hypervisors', 'serials': '/serials', 'deleted_consumers': '/deleted_consumers', 'consumers': '/consumers', 'content': '/content', 'entitlements': '/entitlements', 'consumertypes': '/consumertypes', 'status': '/status', 'jobs': '/jobs', 'users': '/users', 'subscriptions': '/subscriptions', 'rules': '/rules', 'distributor_versions': '/distributor_versions', 'statistics/generate': '/statistics/generate', 'pools': '/pools', 'atom': '/atom', 'owners': '/owners', 'roles': '/roles', 'admin': '/admin', 'events': '/events', 'products': '/products', 'activation_keys': '/activation_keys', 'crl': '/crl'}
2015-11-30 16:50:28,046 [DEBUG] subscription-manager:31788:ServerVersionThread @connection.py:482 - Loaded CA certificates from /etc/rhsm/ca/: candlepin-grimlock.pem, redhat-uep.pem, bundle.pem, ca_bundle.pem
2015-11-30 16:50:28,046 [DEBUG] subscription-manager:31788:ServerVersionThread @connection.py:530 - Making request: GET /candlepin/status
2015-11-30 16:50:28,062 [DEBUG] subscription-manager:31788:ServerVersionThread @connection.py:562 - Response: status=200, requestUuid=4f555cc7-0eeb-4acb-a16b-24b5cdcbe194
2015-11-30 16:50:28,063 [INFO] subscription-manager:31788:ServerVersionThread @managercli.py:368 - Server Versions: {'rules-version': '5.18', 'candlepin': '2.0.9-1', 'server-type': 'Red Hat Subscription Management'}
2015-11-30 16:50:28,084 [ERROR] subscription-manager:31788:MainThread @managercli.py:165 - exception caught in subscription-manager
2015-11-30 16:50:28,084 [ERROR] subscription-manager:31788:MainThread @managercli.py:166 - 'rules-version'
Traceback (most recent call last):
  File "bin/subscription-manager", line 86, in <module>
    sys.exit(abs(main() or 0))
  File "bin/subscription-manager", line 77, in main
    return managercli.ManagerCLI().main()
  File "/home/adrian/src/subscription-manager/src/subscription_manager/managercli.py", line 2686, in main
    return CLI.main(self)
  File "/home/adrian/src/subscription-manager/src/subscription_manager/cli.py", line 160, in main
    return cmd.main()
  File "/home/adrian/src/subscription-manager/src/subscription_manager/managercli.py", line 501, in main
    return_code = self._do_command()
  File "/home/adrian/src/subscription-manager/src/subscription_manager/managercli.py", line 2616, in _do_command
    print (_("subscription management rules: %s") % self.server_versions["rules-version"])
KeyError: 'rules-version'

Comment 3 Adrian Likins 2015-11-30 21:54:38 UTC
Reverting 315d08e880dd07178722e5b6d2c57268a43fc15d  (threading the version check) likely fixes it with the downside of reintroducing 976859

Comment 4 Adrian Likins 2015-11-30 21:57:06 UTC
Adding a default value for 'rules-version' also avoid traceback, but also makes version command fail to show the server version when it can eventually.

Comment 5 Adrian Likins 2015-11-30 23:51:36 UTC
pr at https://github.com/candlepin/subscription-manager/pull/1351

Comment 6 Adrian Likins 2015-12-01 19:10:34 UTC
new pr at https://github.com/candlepin/subscription-manager/pull/1353

Comment 9 John Sefler 2016-03-22 16:02:53 UTC
Verifying Version...

[root@jsefler-6 ~]# rpm -q subscription-manager python-rhsm
subscription-manager-1.16.8-5.el6.x86_64
python-rhsm-1.16.6-1.el6.x86_64

[root@jsefler-6 ~]# rpm -q subscription-manager --changelog | grep 976859
- 976859: Only check server version if asked. (alikins)

[root@jsefler-6 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 2.0.10-1
subscription management rules: 5.19
subscription-manager: 1.16.8-5.el6
python-rhsm: 1.16.6-1.el6


VERIFIED: No more traceback when calling subscription-manager version

Comment 11 errata-xmlrpc 2016-05-10 20:38:14 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.

https://rhn.redhat.com/errata/RHBA-2016-0797.html