Bug 1284120 - Traceback "KeyError: 'rules-version'" is thrown when calling subscription-manager version
Traceback "KeyError: 'rules-version'" is thrown when calling subscription-man...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: subscription-manager (Show other bugs)
6.8
Unspecified Unspecified
high Severity high
: rc
: ---
Assigned To: candlepin-bugs
John Sefler
: Regression, Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-11-20 17:22 EST by John Sefler
Modified: 2016-05-10 16:38 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-05-10 16:38:14 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description John Sefler 2015-11-20 17:22:31 EST
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 16:51:29 EST
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 16:54:38 EST
Reverting 315d08e880dd07178722e5b6d2c57268a43fc15d  (threading the version check) likely fixes it with the downside of reintroducing 976859
Comment 4 Adrian Likins 2015-11-30 16:57:06 EST
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 18:51:36 EST
pr at https://github.com/candlepin/subscription-manager/pull/1351
Comment 6 Adrian Likins 2015-12-01 14:10:34 EST
new pr at https://github.com/candlepin/subscription-manager/pull/1353
Comment 9 John Sefler 2016-03-22 12:02:53 EDT
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@redhat.com)

[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 16:38:14 EDT
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

Note You need to log in before you can comment on or make changes to this bug.