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.
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