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 1656279

Summary: 'subscription-manager status' fails when registration and auto-attach in two steps
Product: Red Hat Enterprise Linux 8 Reporter: qianzhan
Component: subscription-managerAssignee: Nikos Moumoulidis <nmoumoul>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: high Docs Contact:
Priority: high    
Version: 8.0CC: csnyder, nmoumoul, qianzhan, sgao, wchadwic
Target Milestone: rcKeywords: Triaged
Target Release: 8.0Flags: rule-engine: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-14 01:06:43 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:
Bug Depends On: 1633380, 1671734    
Bug Blocks:    
Attachments:
Description Flags
rhsm.log
none
rhsm_log_on_rhel8.0sp3.0 none

Description qianzhan 2018-12-05 07:09:57 UTC
Description of problem:
'subscription-manager status' fails when registration and auto-attach in two steps

Version-Release number of selected component (if applicable):
subscription-manager-1.23.8-4.el8.x86_64
subscription-manager-rhsm-certificates-1.23.8-4.el8.x86_64
python3-subscription-manager-rhsm-1.23.8-4.el8.x86_64
dnf-plugin-subscription-manager-1.23.8-4.el8.x86_64

candlepin-2.5.8-1.el7.noarch
tfm-rubygem-katello-3.10.0-0.2.rc1.el7sat.noarch
katello-3.10.0-0.6.rc1.el7sat.noarch

How reproducible:
always

Steps to Reproduce:
1. Check system status before registration:

[root@dell-r730-002-guest16 ~]# syspurpose show
{
  "addons": [
    ""
  ],
  "service_level_agreement": ""
}


[root@dell-r730-002-guest16 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Unknown

System Purpose Status: Unknown

2. Register RHEL-8.0-20181204.0 against Satellite6.5-snapshot6.0 with auto-attach in one step:


[root@dell-r730-002-guest16 ~]# subscription-manager  register --auto-attach
Registering to: ibm-hs22-04.rhts.eng.brq.redhat.com:443/rhsm
Username: admin
Password: 
The system has been registered with ID: 1d70ac2d-5f11-4c85-a79e-87a95fba0e79
The registered system name is: dell-r730-002-guest16.dsal.lab.eng.rdu2.redhat.com
Failed to synchronize cache for repo 'myrepo_0', ignoring this repo.
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 High Touch Beta
Status:       Subscribed

[root@dell-r730-002-guest16 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Current

System Purpose Status: Unknown

[root@dell-r730-002-guest16 ~]# syspurpose show
{
  "addons": [
    ""
  ],
  "service_level_agreement": ""
}


3. Unregister the system. Registration and auto-attach in two steps, then check system purpose status:

[root@dell-r730-002-guest16 ~]# subscription-manager  unregister
Unregistering from: ibm-hs22-04.rhts.eng.brq.redhat.com:443/rhsm
System has been unregistered.


[root@dell-r730-002-guest16 ~]# subscription-manager  register
Registering to: ibm-hs22-04.rhts.eng.brq.redhat.com:443/rhsm
Username: admin                                                                                                                                                                         
Password: 
The system has been registered with ID: 0e4def5b-b56c-463d-98e0-347273fe6fe0
The registered system name is: dell-r730-002-guest16.dsal.lab.eng.rdu2.redhat.com
Failed to synchronize cache for repo 'myrepo_0', ignoring this repo.


[root@dell-r730-002-guest16 ~]# subscription-manager attach
Failed to synchronize cache for repo 'myrepo_0', ignoring this repo.
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 High Touch Beta
Status:       Subscribed


[root@dell-r730-002-guest16 ~]# syspurpose show
{
  "service_level_agreement": "",
  "addons": [
    ""
  ]
}

[root@dell-r730-002-guest16 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Current

Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 11, in <module>
    load_entry_point('subscription-manager==1.23.8', 'console_scripts', 'subscription-manager')()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/scripts/subscription_manager.py", line 85, in main
    return managercli.ManagerCLI().main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 2882, in main
    ret = CLI.main(self)
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cli.py", line 183, in main
    return cmd.main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 507, in main
    return_code = self._do_command()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 2863, in _do_command
    print(_("System Purpose Status: %s\n") % syspurpose_cache.get_overall_status())
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cache.py", line 335, in get_overall_status
    return self.syspurpose_service.get_overall_status(self.server_status['status'])
TypeError: 'NoneType' object is not subscriptable



Actual results:
As step 3, system purpose status can not be shown with 'subscription-manager status' command when the registration and auto-attach are executed in 2 steps.

Expected results:
There should be no error in step 3.

Additional info:

Comment 1 qianzhan 2018-12-05 07:14:13 UTC
Attachment is rhsm.log

Comment 2 qianzhan 2018-12-05 07:14:37 UTC
Created attachment 1511552 [details]
rhsm.log

Comment 3 Nikos Moumoulidis 2018-12-10 17:10:44 UTC
I cannot reproduce this error using this scenario currently, but I know that the error itself happens when both the server is unreachable, and the syspurpose status cache(/var/lib/rhsm/cache/syspurpose_compliance_status.json) is missing.
A solution to that problem has been posted against https://bugzilla.redhat.com/show_bug.cgi?id=1633380 here: https://github.com/candlepin/subscription-manager/pull/1990

Comment 4 Nikos Moumoulidis 2018-12-17 17:41:15 UTC
Hi, the last couple of lines in the attached log are explaining what happened:

2018-12-05 06:40:05,668 [ERROR] subscription-manager:22974:MainThread @cache.py:236 - HTTP error (404 - Not Found): 
2018-12-05 06:40:05,668 [ERROR] subscription-manager:22974:MainThread @cache.py:239 - Server unreachable, registered, but no cache exists.

I cannot reproduce this with subscription-manager master branch, and I believe it has been fixed by this commit, which will be included in the RHEL 8 snapshot 3 for subscription-manager: 
commit ffe6797e2b8a5c1ed00fcfd11c8516eef5721cad (origin/nikos/1633380_missing_cache_fix)
Author: Nikos Moumoulidis <nmoumoul>
Date:   Fri Dec 7 14:49:27 2018 +0100

    1633380: show syspurpose status Unknown when cache missing
    - When the server is unreachable and the syspurpose status cache
      is missing, then don't traceback, but show status as 'Unknown'.
    - Also, when the server is reachable, but the system is unregisted,
      show the 'Unknown' syspurpose status, but don't cache it.

Can you verify that this issue has been fixed by the above commit? If you are able to still reproduce it after that, could you see if this cache file exists right after this error, and if it does, what its contents are?: /var/lib/rhsm/cache/syspurpose_compliance_status.json

Comment 5 qianzhan 2018-12-19 05:21:16 UTC
Of course, Nikos, I will try it as you said when RHEL8.0-snapshot3 comes.

Comment 6 qianzhan 2018-12-20 08:20:51 UTC
Version-Release number of selected component (if applicable):
python3-subscription-manager-rhsm-1.23.8-11.el8.x86_64
subscription-manager-rhsm-certificates-1.23.8-11.el8.x86_64
dnf-plugin-subscription-manager-1.23.8-11.el8.x86_64
subscription-manager-1.23.8-11.el8.x86_64
katello-3.10.0-0.6.rc1.el7sat.noarch
tfm-rubygem-katello-3.10.0-0.3.rc1.1.el7sat.noarch
candlepin-2.5.8-1.el7.noarch

Verification:
1. Register RHEL-8.0-20181218.0 against Satellite6.5-snapshot8.0:

[root@dell-r730-001-guest22 ~]# subscription-manager  register
Registering to: ibm-hs22-04.rhts.eng.brq.redhat.com:443/rhsm
Username: admin
Password: 
The system has been registered with ID: 3559151a-4a26-4e86-9880-c6c1b52e3c43
The registered system name is: dell-r730-001-guest22.dsal.lab.eng.rdu2.redhat.com

2. Check system purpose status:

[root@dell-r730-001-guest22 ~]# subscription-manager  status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Invalid

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

Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 11, in <module>
    load_entry_point('subscription-manager==1.23.8', 'console_scripts', 'subscription-manager')()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/scripts/subscription_manager.py", line 85, in main
    return managercli.ManagerCLI().main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 2915, in main
    ret = CLI.main(self)
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cli.py", line 183, in main
    return cmd.main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 506, in main
    return_code = self._do_command()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 2896, in _do_command
    print(_("System Purpose Status: %s\n") % syspurpose_cache.get_overall_status())
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cache.py", line 335, in get_overall_status
    return self.syspurpose_service.get_overall_status(self.server_status['status'])
TypeError: 'NoneType' object is not subscriptable

3. Set splay=0, and restart rhsmcertd service:

[root@dell-r730-001-guest22 ~]# service rhsmcertd restart
Redirecting to /bin/systemctl restart rhsmcertd.service

[root@dell-r730-001-guest22 ~]# tail -f /var/log/rhsm/rhsmcertd.log 
Wed Dec 19 21:48:54 2018 [INFO] Waiting 2.0 minutes plus 4632 splay seconds [4752 seconds total] before performing first cert check.
Wed Dec 19 23:08:06 2018 [WARN] (Cert Check) Update failed (255), retry will occur on next run.
Thu Dec 20 03:08:07 2018 [WARN] (Cert Check) Update failed (255), retry will occur on next run.
Thu Dec 20 07:08:13 2018 [INFO] (Cert Check) Certificates updated.
Thu Dec 20 07:16:36 2018 [INFO] rhsmcertd is shutting down...
Thu Dec 20 07:16:36 2018 [INFO] Starting rhsmcertd...
Thu Dec 20 07:16:36 2018 [INFO] Auto-attach interval: 1440.0 minutes [86400 seconds]
Thu Dec 20 07:16:36 2018 [INFO] Cert check interval: 240.0 minutes [14400 seconds]
Thu Dec 20 07:16:36 2018 [INFO] Waiting 2.0 minutes plus 0 splay seconds [120 seconds total] before performing first auto-attach.
Thu Dec 20 07:16:36 2018 [INFO] Waiting 2.0 minutes plus 0 splay seconds [120 seconds total] before performing first cert check.




Thu Dec 20 07:18:42 2018 [INFO] (Cert Check) Certificates updated.
Thu Dec 20 07:18:51 2018 [INFO] (Auto-attach) Certificates updated.

4. 
[root@dell-r730-001-guest22 ~]# subscription-manager  status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Current

Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 11, in <module>
    load_entry_point('subscription-manager==1.23.8', 'console_scripts', 'subscription-manager')()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/scripts/subscription_manager.py", line 85, in main
    return managercli.ManagerCLI().main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 2915, in main
    ret = CLI.main(self)
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cli.py", line 183, in main
    return cmd.main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 506, in main
    return_code = self._do_command()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 2896, in _do_command
    print(_("System Purpose Status: %s\n") % syspurpose_cache.get_overall_status())
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cache.py", line 335, in get_overall_status
    return self.syspurpose_service.get_overall_status(self.server_status['status'])
TypeError: 'NoneType' object is not subscriptable

5. Check syspurpose_compliance_status.json:

[root@dell-r730-001-guest22 ~]# cat /var/lib/rhsm/cache/syspurpose_compliance_status.json
cat: /var/lib/rhsm/cache/syspurpose_compliance_status.json: No such file or directory

[root@dell-r730-001-guest22 ~]# cd /var/lib/rhsm/cache/
[root@dell-r730-001-guest22 cache]# ls
content_overrides.json   installed_products.json    productid_repo_mapping.json  rhsm_icon.json   written_overrides.json
entitlement_status.json  package_repo_mapping.json  profile.json                 syspurpose.json

6. Please see attachment 'rhsm_log_on_rhel8.0sp3.0'

Comment 7 qianzhan 2018-12-20 08:21:12 UTC
Created attachment 1515828 [details]
rhsm_log_on_rhel8.0sp3.0

Comment 8 Nikos Moumoulidis 2018-12-20 13:51:22 UTC
(In reply to qianzhan from comment #6)
> Version-Release number of selected component (if applicable):
> subscription-manager-1.23.8-11.el8.x86_64


It looks like the second commit of 1633380 that fixes this issue has not landed in a build yet:
[vagrant@rhel8 vagrant]$ rpm -q subscription-manager
subscription-manager-1.23.8-11.el8.x86_64
[vagrant@rhel8 vagrant]$ rpm -q --changelog subscription-manager | grep 1633380
- 1633380: Add syspurpose compliance status cache - Altered the syspurpose

Chris, can we include that in the next build?

Comment 9 Chris Snyder 2019-01-10 20:20:26 UTC
Nikos,

I have not yet been able to get the acks necessary to include the second commit in the next build. I will continue to try.

Comment 14 qianzhan 2019-02-13 10:43:08 UTC
Verification on RHEL-8.0.0-20190129.1 against Satellite6.5-snapshot15:

subscription-manager-1.23.8-14.el8.x86_64
candlepin-2.5.8-1.el7.noarch
tfm-rubygem-katello-3.10.0.19-1.el7sat.noarch

[root@ibm-x3650m4-02-vm-06 ~]# subscription-manager register
Registering to: ent-01-vm-01.lab.eng.nay.redhat.com:443/rhsm
Username: admin
Password: 
The system has been registered with ID: 2835125b-6f90-40ae-9c6e-ffc88c9bd87d
The registered system name is: ibm-x3650m4-02-vm-06.lab.eng.bos.redhat.com
[root@ibm-x3650m4-02-vm-06 ~]# subscription-manager attach
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 High Touch Beta
Status:       Subscribed

[root@ibm-x3650m4-02-vm-06 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Current

Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 11, in <module>
    load_entry_point('subscription-manager==1.23.8', 'console_scripts', 'subscription-manager')()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/scripts/subscription_manager.py", line 85, in main
    return managercli.ManagerCLI().main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 2920, in main
    ret = CLI.main(self)
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cli.py", line 183, in main
    return cmd.main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 506, in main
    return_code = self._do_command()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 2901, in _do_command
    print(_("System Purpose Status: %s\n") % syspurpose_cache.get_overall_status())
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cache.py", line 335, in get_overall_status
    return self.syspurpose_service.get_overall_status(self.server_status['status'])
TypeError: 'NoneType' object is not subscriptable

Moving the bug to NEW from ON_QA.

Comment 15 Nikos Moumoulidis 2019-02-13 12:22:51 UTC
(In reply to qianzhan from comment #14)
> Verification on RHEL-8.0.0-20190129.1 against Satellite6.5-snapshot15:
> 
> subscription-manager-1.23.8-14.el8.x86_64

This issue has been fixed as of version subscription-manager-1.23.8-21
Please re-verify with that version.

Comment 16 qianzhan 2019-02-14 10:14:54 UTC
(In reply to Nikos Moumoulidis from comment #15)
> (In reply to qianzhan from comment #14)
> > Verification on RHEL-8.0.0-20190129.1 against Satellite6.5-snapshot15:
> > 
> > subscription-manager-1.23.8-14.el8.x86_64
> 
> This issue has been fixed as of version subscription-manager-1.23.8-21
> Please re-verify with that version.

Verification on RHEL-8.0.0-20190129.1 against Satellite6.5-snapshot15:

subscription-manager-1.23.8-26.el8.x86_64
candlepin-2.5.8-1.el7.noarch
tfm-rubygem-katello-3.10.0.19-1.el7sat.noarch

[root@kvm-02-guest12 ~]# subscription-manager  register
Registering to: ent-01-vm-02.lab.eng.nay.redhat.com:443/rhsm
Username: admin
Password: 
The system has been registered with ID: b49a3f29-b252-4ef9-b20c-525a38e496a1
The registered system name is: kvm-02-guest12.rhts.eng.brq.redhat.com
[root@kvm-02-guest12 ~]# subscription-manager attach
All installed products are covered by valid entitlements. No need to update subscriptions at this time.
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 High Touch Beta
Status:       Subscribed

[root@kvm-02-guest12 ~]# subscription-manager status
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Current

System Purpose Status: Unknown


Moving this bug to VERIFIED.