Bug 1661157

Summary: `syspurpose show` fails with '[Errno -2] Name or service not known" when host is unreachable
Product: Red Hat Enterprise Linux 8 Reporter: Rehana <redakkan>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED WONTFIX QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: low Docs Contact:
Priority: medium    
Version: 8.0CC: jsefler, khowell
Target Milestone: rcKeywords: Triaged
Target Release: 8.0   
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: 2021-02-01 07:31:22 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 Rehana 2018-12-20 08:43:55 UTC
Description of problem:
`syspurpose show` fails with '[Errno -2] Name or service not known" when host is unreachable on both registered and unregistered systems

Version-Release number of selected component (if applicable):
subscription-manager: 1.24.2-1.git.142.1f459b1.el8


How reproducible:
Always

Steps to Reproduce:
On a unregistered system 
========================

1 set some values for syspurpose 
ex: # cat /etc/rhsm/syspurpose/syspurpose.json 
{
  "usage": "Production",
  "addons": [
    "addon1",
    "addon2"
  ],
  "role": "foo"
}
2.configure bad hostname in rhsm.conf
# subscription-manager config --list | grep hostname
   hostname = bad-hostname.usersys.redhat.com

3.Execute `syspurpose show`

On a registered system :
=======================

# subscription-manager register
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: username
Password: 
The system has been registered with ID: 9d28d39e-f27a-4171-92b1-81ab40693497
The registered system name is: dell-r730-001-guest13.dsal.lab.eng.rdu2.redhat.com
[root@dell-r730-001-guest13 test]# syspurpose show
{
  "addons": [
    "addon2",
    "addon1"
  ],
  "role": "foo",
  "usage": "Production"
}
System purpose successfully sent to subscription management server.

Configure host name to a bad name


# subscription-manager config --list | grep hostname
   hostname = BADsubscription.rhsm.stage.redhat.com

# syspurpose show
[Errno -2] Name or service not known



Actual results:
# syspurpose show
[Errno -2] Name or service not known

Expected results:
syspurpose show should display the values saved in the local system when host is not reachable on a unregistered system. 

Additional info:
Notice that on registered system with a bad hostname the subscription-manager status continues to show the last known status 

[root@dell-r730-001-guest13 test]# 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.

System Purpose Status: Unknown

Comment 1 Kevin Howell 2019-01-14 15:33:46 UTC
Let's log the name resolution error, and simply show what's in the file in this scenario.

Comment 5 RHEL Program Management 2021-02-01 07:31:22 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.