Bug 1940308

Summary: [BUG] The / at the end of proxy url is not being handled by satellite correctly when trying to enable repositories
Product: Red Hat Satellite Reporter: Sayan Das <saydas>
Component: RepositoriesAssignee: Justin Sherrill <jsherril>
Status: CLOSED ERRATA QA Contact: Stephen Wadeley <swadeley>
Severity: high Docs Contact:
Priority: medium    
Version: 6.8.0CC: ahumbe, apatel, aruzicka, jbhatia, mhulan, pcreech, pdudley, swadeley
Target Milestone: 6.11.0Keywords: PrioBumpGSS, Triaged, UserExperience
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-4.3.0.2-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-05 14:28:45 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 Sayan Das 2021-03-18 06:20:45 UTC
Description of problem:

The / at the end of proxy URL is not being handled by satellite correctly when trying to enable repositories but works fine while syncing existing repos or refreshing manifest. 


Version-Release number of selected component (if applicable):
6.7, 6.8, and hopefully 6.9 as well

How reproducible:
Always

Steps to Reproduce:
1. Create satellite, import manifest, sync some repos

2. Drop connection to cdn.redhat.com --> iptables -I OUTPUT -d cdn.redhat.com -j DROP

3. Create a proxy server --> http://proxy.example.com:8080

4. Create a HTTP proxy in satellite,
	--> hammer http-proxy create --name myproxy --url http://proxy.example.com:8080/ --organization RedHat
	--> hammer settings set --name content_default_http_proxy --value myproxy

5. Go to Infrastructure --> HTTP proxy --> edit myproxy and perform a test connection against https://aws.amazon.com or https://access.redhat.com

6. Try refreshing manifest

7. Try enabling repos from Content --> Red Hat Repositories page


Actual results:

** Step 5 will be successful.

** Step 6 will also be successful [ at least for customers ]

** At Step 7, when we expand any repository set entry, we will not be able to see any release version or arch to enable. And the "Scan CDN" task will be successful as well.

** On Any version of satellite actual issue can be found in this way,
~~
# hammer repository-set enable --name "Red Hat Satellite Tools 6.7 (for RHEL 7 Server) (RPMs)" --organization XXXX --product "Red Hat Enterprise Linux Server" --basearch "x86_64" --releasever "7Server"
Failed to open TCP connection to http://proxy.example.com/:8080 (getaddrinfo: Name or service not known) http://proxy.example.com:8080/
~~

** On Satellite 6.8 or above, we can use the following rake.

[root@redhat ~]# echo '
  pp HttpProxy.all
  pp Katello::Product.first.cdn_resource.fetch_substitutions("/content/dist/rhel8/")
' | foreman-rake console
Loading production environment (Rails 6.0.3.1)
Switch to inspect mode.

  pp HttpProxy.all
[#<HttpProxy:0x0000000015145518
  id: 1,
  name: "proxy.example.com",
  url: "http://proxy.example.com:8080/",
  username: "",
  password: [FILTERED]>]
#<ActiveRecord::Relation [#<HttpProxy id: 1, name: "proxy.example.com", url: "http://proxy.example.com:8080/", username: "", password: [FILTERED]>]>

  pp Katello::Product.first.cdn_resource.fetch_substitutions("/content/dist/rhel8/")
Traceback (most recent call last):
        4: from lib/tasks/console.rake:5:in `block in <top (required)>'
        3: from (irb):3
        2: from katello (3.16.0.13) app/lib/katello/resources/cdn.rb:129:in `fetch_substitutions'
        1: from katello (3.16.0.13) app/lib/katello/resources/cdn.rb:99:in `get'
SocketError (Failed to open TCP connection to proxy.example.com/:3128 (getaddrinfo: Name or service not known))


As we can see the URL gets malformed here because of the / at the end of proxy URL which was used during proxy creation.

Expected results:

* Either test-connection should fail
* Or, The way during manifest refresh, the trailing / at the end of proxy URL is being ignored, in the same way, for all operations it should be done.


Additional info:

I know that we strictly mention using "--url http://proxy.example.com:8080" but It's very common among customers that they will add / at the end as that is how they have always declared the proxy in env variables.

Comment 4 Paul Dudley 2021-04-14 14:13:21 UTC
*** Bug 1918918 has been marked as a duplicate of this bug. ***

Comment 5 Justin Sherrill 2022-02-01 20:08:44 UTC
Created redmine issue https://projects.theforeman.org/issues/34372 from this bug

Comment 6 Bryan Kearney 2022-02-02 00:03:50 UTC
Upstream bug assigned to jsherril

Comment 7 Bryan Kearney 2022-02-02 00:03:53 UTC
Upstream bug assigned to jsherril

Comment 8 Bryan Kearney 2022-02-05 02:16:54 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34372 has been resolved.

Comment 13 errata-xmlrpc 2022-07-05 14:28:45 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 (Moderate: Satellite 6.11 Release), 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-2022:5498