Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite 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 "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. 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 "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-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 1710697

Summary: Cannot refresh manifest via cdn_proxy after unset global http_proxy setting.
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: SettingsAssignee: Ondřej Ezr <oezr>
Status: CLOSED ERRATA QA Contact: Omkar Khatavkar <okhatavk>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.4.2CC: apatel, dvoss, egolov, mhulan, mkalyat, rbeyel, spetrosi
Target Milestone: 6.6.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foreman-1.22.0.12-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-10-22 19:48:44 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 Hao Chang Yu 2019-05-16 06:14:07 UTC
Description of problem:

If user set a value for "http_proxy" and then unset it. Satellite will set the http_proxy to ''(empty string). This is causing all the outgoing http requests not using proxy including the outgoing traffic to Customer Portal. The katello "cdn_proxy" setting is ignored and Satellite will connect to the Customer Portal directly. Thus, manifest refresh fails.

In "/usr/share/foreman/lib/foreman/http_proxy.rb"

    # Answers if this request should be proxied
    def proxy_http_request?(current_proxy, request_host, schema)
      !http_proxy.nil? &&     <========== This is using ".nil?" which will return false for empty string. Suggest to use ".blank?" which should fix the issue.
      current_proxy.nil? &&
      !request_host.nil? &&
      http_request?(schema) &&
      http_proxy_host?(request_host) &&
      !local_request?(request_host)
    end


Steps to Reproduce:
1. http_proxy setting is nil in the beginning.

echo "select id,name,value from settings where name = 'http_proxy'" | su postgres -c 'psql foreman'
 id  |    name    | value 
-----+------------+-------
 108 | http_proxy |

2. Go to the Setting page set the http_proxy to any url, such as http://proxy.example.com and save it.

echo "select id,name,value from settings where name = 'http_proxy'" | su postgres -c 'psql foreman'
 id  |    name    |            value             
-----+------------+------------------------------
 108 | http_proxy | --- http://proxy.example.com+
     |            | ...

3. Still in the Setting page unset the http_proxy and save it.

echo "select name,value from settings where name = 'http_proxy'" | su postgres -c 'psql foreman'
    name    | value  
------------+--------
 http_proxy | --- ''

4. Block your Satellite to connect to the Customer portal directly.

5. Set the cdn_proxy in etc/foreman/plugins/katello.yaml

  :cdn_proxy:
    :host: http://proxy.example.com
    :port: 3128
    :user: hao
    :password: mypassword

6. Restart Satellite.

7. Refresh Manifest and the Foreman task should fail with connection error.

8. Check the production.log, you should see something like.

[app] [I] Proxying request to subscription.rhsm.redhat.com via

Comment 6 Marek Hulan 2019-05-20 06:42:49 UTC
Created redmine issue https://projects.theforeman.org/issues/26828 from this bug

Comment 7 Bryan Kearney 2019-07-14 16:03:00 UTC
Upstream bug assigned to oezr

Comment 8 Bryan Kearney 2019-07-14 16:03:02 UTC
Upstream bug assigned to oezr

Comment 9 Bryan Kearney 2019-07-15 14:02:55 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/26828 has been resolved.

Comment 12 Omkar Khatavkar 2019-08-19 08:19:15 UTC
Verified on Satellite 6.6 Snap 16 with an unset in http_proxy not able to see an error in production log.  and fix look working as 

irb(main):002:0> Setting[:http_proxy].presence
=> nil

Comment 13 Omkar Khatavkar 2019-08-19 08:19:28 UTC
Verified on Satellite 6.6 Snap 16 with an unset in http_proxy not able to see an error in production log.  and fix look working as 

irb(main):002:0> Setting[:http_proxy].presence
=> nil

Comment 17 Bryan Kearney 2019-10-22 19:48:44 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://access.redhat.com/errata/RHSA-2019:3172