Bug 1661157 - `syspurpose show` fails with '[Errno -2] Name or service not known" when host is unreachable
Summary: `syspurpose show` fails with '[Errno -2] Name or service not known" when host...
Keywords:
Status: NEW
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: subscription-manager
Version: 8.0
Hardware: Unspecified
OS: Unspecified
medium
low
Target Milestone: rc
: 8.0
Assignee: candlepin-bugs
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-12-20 08:43 UTC by Rehana
Modified: 2019-12-01 15:56 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)

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.


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