Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 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 "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". 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 "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-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 2159208

Summary: dnf copr enable doesn't work behind firewall
Product: Red Hat Enterprise Linux 9 Reporter: Tomasz Kepczynski <tomek>
Component: dnf-plugins-coreAssignee: Copr Team <copr-team>
Status: CLOSED DEFERRED QA Contact: swm-qe
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.1CC: amatej, james.antill, msuchy, praiskup
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-03-08 15:14:46 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 Tomasz Kepczynski 2023-01-09 07:47:49 UTC
Description of problem:
I am located behind firewall and have to use HTTP/HTTPS proxy for any outgoing internet connections. Hence I configured proxy setting in /etc/dnf/dnf.conf (proxy=http://<redacted_hostname>:912/). This works for regular installation and updates.
It does not work for:
# dnf copr enable tomkep/epel-extras
command.
The command displays the usual disclaimer and waits for confirmation to continue which is given. The command then hangs for the couple of minutes and timeouts with the following error:
Error: Failed to connect to https://copr.fedorainfracloud.org/coprs/tomkep/epel-extras/repo/epel-9/dnf.repo?arch=x86_64: Network is unreachable

Judging from netstat the command is attempting DIRECT connection to the Internet:
tcp        0      1 172.28.38.82:55956      3.225.109.36:443        SYN_SENT    15594/python3       
which for the above-mentioned reason obviously fails.

Version-Release number of selected component (if applicable):
dnf-data-4.12.0-4.el9.alma.noarch
dnf-4.12.0-4.el9.alma.noarch
dnf-plugins-core-4.1.0-3.el9.noarch

How reproducible:
Always

Actual results:
The command timeouts and fails to setup copr repository.

Expected results:
The command works.

Additional info:
The repository works correctly once the configuration file is put in place by hand.
Found on AlmaLinux 9.1.

Comment 1 amatej 2023-01-10 07:16:45 UTC
Since normal install and updates work this issue is probably specific to copr. 
I am assigning the copr team.

Comment 2 Pavel Raiskup 2023-01-10 08:00:38 UTC
Thank you for the report!

I'm not sure, can anyone from the DNF team confirm that the problem is
that we use urllib.request.urlopen() instead of the DNF's
dnf.cli.Command.base.urlopen()?  Would that use the configured proxy?

https://github.com/rpm-software-management/dnf-plugins-core/blob/3e0267e2a6b95640f2642813d8a96e18c6292ba5/plugins/copr.py#L499

Comment 3 Tomasz Kepczynski 2023-01-10 08:04:35 UTC
If you give me patched rpm I can test this for you.

Comment 4 Pavel Raiskup 2023-01-10 09:12:00 UTC
This is a bit complicated.  IIRC Silvie used the
urllib.request.urlopen() method because in case of a 404 error,
we need to reed the HTTP header provided by Copr Frontend.

Namely the base64-encoded header `Copr-Error-Data`:
https://github.com/rpm-software-management/dnf-plugins-core/blob/3e0267e2a6b95640f2642813d8a96e18c6292ba5/plugins/copr.py#L507

If we got it right those days, it is not possible to read
the headers from error 404/403 responses with the DNF's
built-in urlopen() method.

Comment 5 Miroslav Suchý 2023-03-08 15:14:46 UTC
This never worked in the past. So it is more RFE than a bug.

It is useful RFE though. I will track it upstream at https://bugzilla.redhat.com/show_bug.cgi?id=2176531 and I am going to close this one. 

Even if we implement it in the future, I do not plan to backport it to EL9 unless it is required by a customer through our support.