Bug 1301215

Summary: The cmd "repos --list --proxy" with a fake proxy server url will not stop running.
Product: Red Hat Enterprise Linux 6 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: William Poteat <wpoteat>
Status: CLOSED ERRATA QA Contact: John Sefler <jsefler>
Severity: low Docs Contact:
Priority: high    
Version: 6.8CC: alikins, bcourt, csnyder, ldai, redakkan, vrjain, wpoteat
Target Milestone: rcKeywords: Regression, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1306004 (view as bug list) Environment:
Last Closed: 2017-03-21 10:54:30 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:    
Bug Blocks: 1306004    
Attachments:
Description Flags
rhsm.log from call to "subscription-manager repos --list-enabled --proxy=www.baidu.com" none

Description John Sefler 2016-01-22 21:44:11 UTC
Created attachment 1117339 [details]
rhsm.log from call to "subscription-manager repos --list-enabled --proxy=www.baidu.com"

Description of problem:
Effectively I am re-opening original bug 968820 which states...

     After register and subscribe for the system, the cmd "repos --list
     --proxy" with a fake proxy server url will not stop running.

Actually it does stop running, but it takes a long time and the results appear to be successful (from cache) but why?  There is no indication for the apparently successful results.

Version-Release number of selected component (if applicable):
[root@jsefler-6 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 0.9.51.15-1
subscription management rules: 5.15.1
subscription-manager: 1.16.8-1.el6
python-rhsm: 1.16.6-1.el6


How reproducible:


Steps to Reproduce:
register and attach a subscription (not shown), then...

[root@jsefler-6 ~]# echo "" > /var/log/rhsm/rhsm.log
[root@jsefler-6 ~]# 
[root@jsefler-6 ~]# time subscription-manager repos --list-enabled --proxy=www.baidu.com
+----------------------------------------------------------+
    Available Repositories in /etc/yum.repos.d/redhat.repo
+----------------------------------------------------------+
Repo ID:   rhel-6-server-rpms
Repo Name: Red Hat Enterprise Linux 6 Server (RPMs)
Repo URL:  https://cdn.qa.redhat.com/content/dist/rhel/server/6/$releasever/$basearch/os
Enabled:   1


real	7m25.269s
user	0m0.986s
sys	0m0.286s
[root@jsefler-6 ~]# echo $?
0
[root@jsefler-6 ~]# 
[root@jsefler-6 ~]# grep ERROR /var/log/rhsm/rhsm.log
2016-01-22 16:20:51,196 [ERROR] subscription-manager:14351 @entcertlib.py:121 - [Errno 110] Connection timed out
2016-01-22 16:20:51,202 [ERROR] subscription-manager:14351 @entcertlib.py:122 - Cannot modify subscriptions while disconnected
2016-01-22 16:20:51,206 [ERROR] subscription-manager:14351 @base_action_client.py:73 - 
2016-01-22 16:21:55,306 [ERROR] subscription-manager:14351 @base_action_client.py:73 - [Errno 110] Connection timed out
2016-01-22 16:23:00,008 [ERROR] subscription-manager:14351 @repolib.py:222 - [Errno 110] Connection timed out
2016-01-22 16:24:03,097 [ERROR] subscription-manager:14351 @cache.py:229 - [Errno 110] Connection timed out
2016-01-22 16:25:06,673 [ERROR] subscription-manager:14351 @cache.py:229 - [Errno 110] Connection timed out
2016-01-22 16:26:09,770 [ERROR] subscription-manager:14351 @repolib.py:222 - [Errno 110] Connection timed out
2016-01-22 16:27:12,805 [ERROR] subscription-manager:14351 @cache.py:229 - [Errno 110] Connection timed out
[root@jsefler-6 ~]# 




Actual results:
Notice that it took over 7 minutes to get a response.  Once it came, the exitcode was a successful 0 and the results appear good.  How was that possible given an invalid proxy?
Notice that there were nine errors logged for this call including seven timeouts.


Expected results:
Originally this test reported the following stderr with an exitcode of 70 (EX_SOFTWARE)
Network error, unable to connect to server. Please see /var/log/rhsm/rhsm.log for more information.

Today I'm not sure what to expect.  Two possibilities incluide:
  A. a Network Error just like the original
  B. a cached result (with some indicator that it came from cache).


Additional info:

Comment 4 Chris Snyder 2016-04-26 18:02:56 UTC
A fix for this is available in upstream master as of the commit below

commit 7ce6801fc1cc38edcdeb75dfb5f0d1f8a6398c68
Author: William Poteat <wpoteat>
Date:   Tue Mar 1 13:30:41 2016 -0500

    1301215: Test proxy connection before making call
    1176219: Stop before cache is returned when using bad proxy options
    
    Uses socket connect as test for viability of proxy. Only checks when proxy
    settings are on the command line.

Comment 7 Rehana 2016-12-12 15:25:04 UTC
Verifying with :
subscription management server: 0.9.51.20-1
subscription management rules: 5.15.1
subscription-manager: 1.18.6-1.el6
python-rhsm: 1.18.6-1.el6

# subscription-manager register
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: qa
Password: 
The system has been registered with ID: 49464c16-726f-4dc3-a1d4-f5f70ec11c50 
[root@dhcp70-150 rhn]# subscription-manager attach --auto


Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed


# time subscription-manager repos --list-enabled --proxy=www.baidu.com
Proxy connection failed, please check your settings.

real	0m14.596s
user	0m0.157s
sys	0m0.037s


==========================

2016-12-12 08:34:23,134 [DEBUG] subscription-manager:29168:MainThread @https.py:59 - Using m2crypto wrappers to provide httplib and ssl
2016-12-12 08:34:23,239 [DEBUG] subscription-manager:29168:MainThread @ga_loader.py:89 - ga_loader GaImporterGtk2
2016-12-12 08:34:23,242 [DEBUG] subscription-manager:29168:MainThread @plugins.py:569 - loaded plugin modules: []
2016-12-12 08:34:23,242 [DEBUG] subscription-manager:29168:MainThread @plugins.py:570 - loaded plugins: {}
2016-12-12 08:34:23,242 [DEBUG] subscription-manager:29168:MainThread @identity.py:131 - Loading consumer info from identity certificates.
2016-12-12 08:34:23,268 [INFO] subscription-manager:29168:MainThread @managercli.py:389 - Client Versions: {'python-rhsm': '1.18.6-1.el6', 'subscription-manager': '1.18.6-1.el6'}
2016-12-12 08:34:23,268 [INFO] subscription-manager:29168:MainThread @connection.py:758 - Connection built: http_proxy=www.baidu.com:3128 host=subscription.rhsm.stage.redhat.com port=443 handler=/subscription auth=identity_cert ca_dir=/etc/rhsm/ca/ insecure=False
2016-12-12 08:34:23,269 [INFO] subscription-manager:29168:MainThread @connection.py:758 - Connection built: http_proxy=www.baidu.com:3128 host=subscription.rhsm.stage.redhat.com port=443 handler=/subscription auth=none

Observed that repo list now fails with error message "Proxy connection failed, please check your settings." and it no longer hangs.

Marking as Verified!!

Comment 9 errata-xmlrpc 2017-03-21 10:54:30 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, 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://rhn.redhat.com/errata/RHSA-2017-0698.html