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 2189664 - subscription-manager status throws a... 'NoneType' object has no attribute 'get' after configuring a bad proxy
Summary: subscription-manager status throws a... 'NoneType' object has no attribute 'g...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: subscription-manager
Version: 9.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 9.3
Assignee: Pino Toscano
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-04-25 20:39 UTC by John Sefler
Modified: 2023-11-07 11:20 UTC (History)
0 users

Fixed In Version: subscription-manager-1.29.35-1.el9
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-11-07 08:51:53 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github candlepin subscription-manager pull 3252 0 None Merged 2189664: cache: fix SyspurposeComplianceStatusCache on failed load 2023-05-16 10:25:27 UTC
Red Hat Issue Tracker RHELPLAN-155774 0 None None None 2023-04-25 20:40:02 UTC
Red Hat Product Errata RHBA-2023:6606 0 None None None 2023-11-07 08:52:11 UTC

Description John Sefler 2023-04-25 20:39:30 UTC
Description of problem:
After setting a bad proxy on a registered system, a call to subscription-manager status encounters "'NoneType' object has no attribute 'get'".  This was handled more gracefully on RHEL-9.2


Version-Release number of selected component (if applicable):
[root@kvm-02-guest13 ~]# rpm -q subscription-manager
subscription-manager-1.29.34-1.el9.x86_64


How reproducible:


Steps to Reproduce:
[root@kvm-02-guest13 ~]# subscription-manager register --username=stage_rhsmqe_testuser01 
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Password: 
The system has been registered with ID: 2e081dce-45e3-4023-9a40-0f81c5ed7034
The registered system name is: kvm-02-guest13.lab.eng.rdu2.redhat.com
[root@kvm-02-guest13 ~]# 
[root@kvm-02-guest13 ~]# subscription-manager config --server.proxy_hostname=bad-proxy --server.proxy_port=3127
[root@kvm-02-guest13 ~]# 
[root@kvm-02-guest13 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Invalid

Red Hat Enterprise Linux for x86_64 Beta:
- Not supported by a valid subscription.

System Purpose Status: Unknown
'NoneType' object has no attribute 'get'
[root@kvm-02-guest13 ~]# echo $?
70


Actual results:
  above

Expected results:
  exitCode 1 (without the 'NoneType' object error)


Additional info:
root@kvm-02-guest13 ~]# tail -25 /var/log/rhsm/rhsm.log
2023-04-25 16:30:34,568 [DEBUG] subscription-manager:163597:MainThread @connection.py:1117 - Making request: GET /subscription/status
2023-04-25 16:30:34,569 [DEBUG] subscription-manager:163597:MainThread @connection.py:756 - Creating new connection
2023-04-25 16:30:34,570 [DEBUG] subscription-manager:163597:MainThread @connection.py:726 - Loaded CA certificates from /etc/rhsm/ca/: redhat-entitlement-authority.pem, redhat-uep.pem
2023-04-25 16:30:34,571 [DEBUG] subscription-manager:163597:MainThread @connection.py:781 - Using proxy: bad-proxy:3127
2023-04-25 16:30:34,722 [DEBUG] subscription-manager:163597:MainThread @files.py:296 - Failed to detect whether the server has syspurpose capability: Proxy error at bad-proxy:3127: [Errno -2] Name or service not known
2023-04-25 16:30:34,722 [DEBUG] subscription-manager:163597:MainThread @files.py:651 - Successfully updated syspurpose values at '/etc/rhsm/syspurpose/syspurpose.json'.
2023-04-25 16:30:34,722 [DEBUG] subscription-manager:163597:MainThread @files.py:652 - Failed to update syspurpose values at '/etc/rhsm/syspurpose/syspurpose.json'.
2023-04-25 16:30:34,723 [DEBUG] subscription-manager:163597:MainThread @connection.py:1117 - Making request: GET /subscription/status
2023-04-25 16:30:34,723 [DEBUG] subscription-manager:163597:MainThread @connection.py:756 - Creating new connection
2023-04-25 16:30:34,724 [DEBUG] subscription-manager:163597:MainThread @connection.py:726 - Loaded CA certificates from /etc/rhsm/ca/: redhat-entitlement-authority.pem, redhat-uep.pem
2023-04-25 16:30:34,725 [DEBUG] subscription-manager:163597:MainThread @connection.py:781 - Using proxy: bad-proxy:3127
2023-04-25 16:30:34,876 [ERROR] subscription-manager:163597:MainThread @cache.py:260 - Proxy error at bad-proxy:3127: [Errno -2] Name or service not known
2023-04-25 16:30:34,876 [ERROR] subscription-manager:163597:MainThread @cache.py:263 - Server unreachable, registered, but no cache exists.
2023-04-25 16:30:34,876 [ERROR] subscription-manager:163597:MainThread @cli.py:71 - exception caught in subscription-manager
2023-04-25 16:30:34,877 [ERROR] subscription-manager:163597:MainThread @cli.py:72 - 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
  File "/usr/lib64/python3.9/site-packages/subscription_manager/cli_command/cli.py", line 412, in main
    return_code = self._do_command()
  File "/usr/lib64/python3.9/site-packages/subscription_manager/cli_command/status.py", line 169, in _do_command
    self._print_syspurpose_status(on_date)
  File "/usr/lib64/python3.9/site-packages/subscription_manager/cli_command/status.py", line 147, in _print_syspurpose_status
    syspurpose_status_code = syspurpose_cache.get_overall_status_code()
  File "/usr/lib64/python3.9/site-packages/subscription_manager/cache.py", line 397, in get_overall_status_code
    return self.server_status.get("status", "unknown")
AttributeError: 'NoneType' object has no attribute 'get'

Comment 1 John Sefler 2023-04-25 20:44:21 UTC
For comparison, the same scenario on RHEL-9.2 follows with more graceful error handling...

[root@kvm-03-guest21 ~]# rpm -q subscription-manager
subscription-manager-1.29.33.1-1.el9_2.x86_64
[root@kvm-03-guest21 ~]# subscription-manager register --username=stage_rhsmqe_testuser01 
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Password: 
The system has been registered with ID: f7dfc179-6e01-4fc4-93a8-7081df9866c5
The registered system name is: kvm-03-guest21.lab.eng.rdu2.redhat.com
[root@kvm-03-guest21 ~]# 
[root@kvm-03-guest21 ~]# subscription-manager config --server.proxy_hostname=bad-proxy --server.proxy_port=3127
[root@kvm-03-guest21 ~]# 
[root@kvm-03-guest21 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Invalid

Red Hat Enterprise Linux for x86_64:
- Not supported by a valid subscription.

System Purpose Status: Unknown

[root@kvm-03-guest21 ~]# echo $?
1
[root@kvm-03-guest21 ~]# 
[root@kvm-03-guest21 ~]# tail -6 /var/log/rhsm/rhsm.log 
2023-04-25 16:34:06,233 [ERROR] subscription-manager:21132:MainThread @cache.py:245 - Proxy error at bad-proxy:3127: [Errno -2] Name or service not known
2023-04-25 16:34:06,233 [WARNING] subscription-manager:21132:MainThread @cache.py:251 - Unable to reach server, using cached status.
2023-04-25 16:34:06,384 [ERROR] subscription-manager:21132:MainThread @cache.py:245 - Proxy error at bad-proxy:3127: [Errno -2] Name or service not known
2023-04-25 16:34:06,385 [WARNING] subscription-manager:21132:MainThread @cache.py:251 - Unable to reach server, using cached status.
2023-04-25 16:34:06,840 [ERROR] subscription-manager:21132:MainThread @cache.py:245 - Proxy error at bad-proxy:3127: [Errno -2] Name or service not known
2023-04-25 16:34:06,840 [ERROR] subscription-manager:21132:MainThread @cache.py:248 - Server unreachable, registered, but no cache exists.
[root@kvm-03-guest21 ~]#

Comment 2 Pino Toscano 2023-04-27 04:50:47 UTC
Reproduced easily (though I really needed to change the config, rather than pass --proxy to 'sub-man status'), thanks.
This is a small regression introduced by the recent internal cache rework (part of [1]); nothing bad in the end, simply a lack of tests (sigh), hopefully easily fixed by:
https://github.com/candlepin/subscription-manager/pull/3252

[1] https://github.com/candlepin/subscription-manager/pull/3225

Comment 9 errata-xmlrpc 2023-11-07 08:51:53 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 (subscription-manager bug fix and enhancement update), 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://access.redhat.com/errata/RHBA-2023:6606


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