Bug 1862415

Summary: unexpected 'displayName' after a consumer has been deleted on the server side; expected a graceful GoneException
Product: Red Hat Enterprise Linux 8 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: Jiri Hnidek <jhnidek>
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: high Docs Contact:
Priority: high    
Version: 8.3CC: csnyder, jhnidek, redakkan, skallesh, wpoteat
Target Milestone: rcKeywords: Regression, Triaged
Target Release: 8.3   
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: 2020-11-04 01:39:41 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 2020-07-31 11:49:12 UTC
Description of problem:
  When a consumer has been deleted at the server, the expected message on the client should come from a GoneException "Unit 6ab68937-3918-487f-837e-cf6e87650b9f has been deleted".  Instead we are getting a 'displayName'.


Version-Release number of selected component (if applicable):
[root@hpe-dl380pgen8-02-vm-11 ~]# rpm -q subscription-manager
subscription-manager-1.27.11-1.el8.x86_64


How reproducible:


Steps to Reproduce:
[root@hpe-dl380pgen8-02-vm-11 ~]# subscription-manager register --auto-attach --serverurl=subscription.rhsm.stage.redhat.com
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: stage_auto_testuser
Password: 
CACHED_SYSPURPOSE: /var/lib/rhsm/cache/syspurpose.json
The system has been registered with ID: e1ba85c0-20c5-444d-89b5-e57dabaa3a15
The registered system name is: hpe-dl380pgen8-02-vm-11.hpe2.lab.eng.bos.redhat.com
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 Beta
Status:       Subscribed

[root@hpe-dl380pgen8-02-vm-11 ~]# curl --stderr /dev/null --insecure --user stage_auto_testuser:REDACTED --request DELETE https://candlepin.corp.stage.redhat.com/candlepin/consumers/e1ba85c0-20c5-444d-89b5-e57dabaa3a15
[root@hpe-dl380pgen8-02-vm-11 ~]# 
[root@hpe-dl380pgen8-02-vm-11 ~]# sleep 60
[root@hpe-dl380pgen8-02-vm-11 ~]# 
[root@hpe-dl380pgen8-02-vm-11 ~]# subscription-manager identity
'displayName'
[root@hpe-dl380pgen8-02-vm-11 ~]# 


Actual results:
  'displayName'

Expected results:
  Unit 6ab68937-3918-487f-837e-cf6e87650b9f has been deleted

Additional info:

[root@hpe-dl380pgen8-02-vm-11 ~]# tail -20 /var/log/rhsm/rhsm.log 
2020-07-31 07:39:12,443 [DEBUG] subscription-manager:452514:MainThread @connection.py:265 - Connection built: host=subscription.rhsm.stage.redhat.com port=443 handler=/subscription auth=identity_cert ca_dir=/etc/rhsm/ca/ insecure=False
2020-07-31 07:39:12,443 [DEBUG] subscription-manager:452514:MainThread @connection.py:169 - Environment variable NO_PROXY= will be used
2020-07-31 07:39:12,443 [DEBUG] subscription-manager:452514:MainThread @connection.py:265 - Connection built: host=subscription.rhsm.stage.redhat.com port=443 handler=/subscription auth=none
2020-07-31 07:39:12,533 [DEBUG] subscription-manager:452514:MainThread @managercli.py:367 - Consumer Identity name=hpe-dl380pgen8-02-vm-11.hpe2.lab.eng.bos.redhat.com uuid=e1ba85c0-20c5-444d-89b5-e57dabaa3a15
2020-07-31 07:39:12,534 [DEBUG] subscription-manager:452514:MainThread @cache.py:881 - Trying to read CurrentOwnerCache from cache file /var/lib/rhsm/cache/current_owner.json
2020-07-31 07:39:12,535 [DEBUG] subscription-manager:452514:MainThread @cache.py:887 - Identity of system has changed. The cache file: /var/lib/rhsm/cache/current_owner.json is obsolete
2020-07-31 07:39:12,535 [DEBUG] subscription-manager:452514:MainThread @cache.py:897 - Getting data from server for <class 'subscription_manager.cache.CurrentOwnerCache'>
2020-07-31 07:39:12,535 [DEBUG] subscription-manager:452514:MainThread @connection.py:685 - Making request: GET /subscription/consumers/e1ba85c0-20c5-444d-89b5-e57dabaa3a15/owner
2020-07-31 07:39:12,536 [DEBUG] subscription-manager:452514:MainThread @connection.py:570 - Loaded CA certificates from /etc/rhsm/ca/: redhat-entitlement-authority.pem, redhat-uep.pem
2020-07-31 07:39:13,025 [DEBUG] subscription-manager:452514:MainThread @connection.py:779 - Response time: 0.4092395305633545, Smoothed response time: 0.4092395305633545
2020-07-31 07:39:13,025 [DEBUG] subscription-manager:452514:MainThread @connection.py:756 - Response: status=410, requestUuid=222aa111-e0ae-4b8e-9047-858d3979639e, request="GET /subscription/consumers/e1ba85c0-20c5-444d-89b5-e57dabaa3a15/owner"
2020-07-31 07:39:13,026 [WARNING] subscription-manager:452514:MainThread @cache.py:901 - Unable to get data for <class 'subscription_manager.cache.CurrentOwnerCache'> using REST API: HTTP error (410 - Gone): Unit e1ba85c0-20c5-444d-89b5-e57dabaa3a15 has been deleted
2020-07-31 07:39:13,026 [DEBUG] subscription-manager:452514:MainThread @cache.py:902 - Deleting cache file: /var/lib/rhsm/cache/current_owner.json
2020-07-31 07:39:13,027 [DEBUG] subscription-manager:452514:MainThread @cache.py:93 - Deleting cache: /var/lib/rhsm/cache/current_owner.json
2020-07-31 07:39:13,027 [ERROR] subscription-manager:452514:MainThread @managercli.py:218 - Error: Unable to generate a new identity for the system
2020-07-31 07:39:13,027 [ERROR] subscription-manager:452514:MainThread @managercli.py:219 - 'displayName'
Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 1103, in _do_command
    ownername = owner['displayName']
KeyError: 'displayName'

Comment 1 Shwetha Kallesh 2020-08-05 10:15:13 UTC
*** Bug 1866280 has been marked as a duplicate of this bug. ***

Comment 4 John Sefler 2020-08-31 15:53:05 UTC
Verifying Version...

[root@ibm-x3650m4-01-vm-06 ~]# rpm -q subscription-manager
subscription-manager-1.27.15-1.el8.x86_64
[root@ibm-x3650m4-01-vm-06 ~]# rpm -q subscription-manager --changelog | grep 1862415
- 1862415: Print proper message, when consumer is deleted; ENT-2709
[root@ibm-x3650m4-01-vm-06 ~]# 


[root@ibm-x3650m4-01-vm-06 ~]# subscription-manager register --auto-attach --serverurl=subscription.rhsm.stage.redhat.com
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: stage_auto_testuser
Password: 
The system has been registered with ID: 0b9adffd-066d-4e4a-91c9-3f55113f4190
The registered system name is: ibm-x3650m4-01-vm-06.ibm2.lab.eng.bos.redhat.com
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 High Touch Beta
Status:       Subscribed

[root@ibm-x3650m4-01-vm-06 ~]# curl --stderr /dev/null --insecure --user stage_auto_testuser:REDACTED --request DELETE  https://candlepin.corp.stage.redhat.com/candlepin/consumers/0b9adffd-066d-4e4a-91c9-3f55113f4190
[root@ibm-x3650m4-01-vm-06 ~]# 
[root@ibm-x3650m4-01-vm-06 ~]# 
[root@ibm-x3650m4-01-vm-06 ~]# sleep 60
[root@ibm-x3650m4-01-vm-06 ~]# 
[root@ibm-x3650m4-01-vm-06 ~]# subscription-manager identity
Consumer profile "0b9adffd-066d-4e4a-91c9-3f55113f4190" has been deleted from the server. You can use command clean or unregister to remove local profile.
[root@ibm-x3650m4-01-vm-06 ~]# 
[root@ibm-x3650m4-01-vm-06 ~]# tail -n2 /var/log/rhsm/rhsm.log
2020-08-31 11:07:57,641 [WARNING] subscription-manager:15463:MainThread @cache.py:901 - Unable to get data for <class 'subscription_manager.cache.CurrentOwnerCache'> using REST API: HTTP error (410 - Gone): Unit 0b9adffd-066d-4e4a-91c9-3f55113f4190 has been deleted
2020-08-31 11:07:57,641 [CRITICAL] subscription-manager:15463:MainThread @managercli.py:559 - Consumer profile "0b9adffd-066d-4e4a-91c9-3f55113f4190" has been deleted from the server.
[root@ibm-x3650m4-01-vm-06 ~]# 

VERIFIED:  A graceful message is now presented to the user with instructions how to proceed....


[root@ibm-x3650m4-01-vm-06 ~]# subscription-manager identity
Consumer profile "0b9adffd-066d-4e4a-91c9-3f55113f4190" has been deleted from the server. You can use command clean or unregister to remove local profile.
[root@ibm-x3650m4-01-vm-06 ~]# 
[root@ibm-x3650m4-01-vm-06 ~]# subscription-manager unregister
Unregistering from: subscription.rhsm.stage.redhat.com:443/subscription
System has been unregistered.
[root@ibm-x3650m4-01-vm-06 ~]# 
[root@ibm-x3650m4-01-vm-06 ~]# subscription-manager identity
This system is not yet registered. Try 'subscription-manager register --help' for more information.
[root@ibm-x3650m4-01-vm-06 ~]# 

VERIFIED: The instruction to unregister also removes the local profile gracefully.

Comment 7 errata-xmlrpc 2020-11-04 01:39:41 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-2020:4460