Bug 1628888

Summary: can't enable copr repository using Rawhide
Product: [Fedora] Fedora Reporter: Bruno Goncalves <bgoncalv>
Component: dnfAssignee: Miroslav Suchý <msuchy>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 31CC: astepano, dmach, dustymabe, jmracek, mblaha, mvadkert, packaging-team-maint, pkratoch, rpm-software-management, vmukhame
Target Milestone: ---Keywords: 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: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Bruno Goncalves 2018-09-14 09:21:37 UTC
Description of problem:

# dnf copr enable -y mvadkert/beakerlib-libraries
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/dnf/util.py", line 128, in _urlopen
    libdnf.repo.Downloader.downloadURL(conf._config if conf else None, url, fo.fileno())
RuntimeError: Status code: 404 for https://copr.fedorainfracloud.org/coprs/mvadkert/beakerlib-libraries/repo/fedora-30/

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 179, in user_main
    errcode = main(args)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 99, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 115, in cli_run
    cli.run()
  File "/usr/lib/python3.7/site-packages/dnf/cli/cli.py", line 1049, in run
    return self.command.run()
  File "/usr/lib/python3.7/site-packages/dnf-plugins/copr.py", line 200, in run
    self._download_repo(project_name, repo_filename, chroot)
  File "/usr/lib/python3.7/site-packages/dnf-plugins/copr.py", line 339, in _download_repo
    f = self.base.urlopen(self.copr_url + api_path, mode='w+')
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 2311, in urlopen
    return dnf.util._urlopen(url, self.conf, repo, mode, **kwargs)
  File "/usr/lib/python3.7/site-packages/dnf/util.py", line 130, in _urlopen
    raise IOError(e.args[1])
IndexError: tuple index out of range


Version-Release number of selected component (if applicable):
dnf-3.5.1-1.fc30.noarch
Fedora-Cloud-Base-Rawhide-20180913.n.0.x86_64.qcow2

How reproducible:
100%

Steps to Reproduce:
1.Download qcow2 image
For example from: 

https://kojipkgs.fedoraproject.org/compose/rawhide/latest-Fedora-Rawhide/compose/Cloud/x86_64/images/

https://jenkins-continuous-infra.apps.ci.centos.org/view/all/job/fedora-rawhide-image-test/lastSuccessfulBuild/artifact/Fedora-Rawhide.qcow2

2.Bring VM up and connect to it
3.Try to enable some copr repo
dnf copr enable -y mvadkert/beakerlib-libraries


Actual results:
it tries to use URL for Fedora-30, but it should use rawhide one.

Expected results:
copr repo should be enable correctly

Additional info:
# cat /etc/os-release 
NAME=Fedora
VERSION="30 (Cloud Edition)"
ID=fedora
VERSION_ID=30
PLATFORM_ID="platform:f30"
PRETTY_NAME="Fedora 30 (Cloud Edition)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:30"
HOME_URL="https://fedoraproject.org/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=rawhide
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=rawhide
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Cloud Edition"
VARIANT_ID=cloud

Comment 1 Miroslav Vadkerti 2018-09-14 09:31:49 UTC
Just to note, there are 2 issues here really:

1. This seems clearly a bug:

  File "/usr/lib/python3.7/site-packages/dnf/util.py", line 130, in _urlopen
    raise IOError(e.args[1])
IndexError: tuple index out of range


2. We have no idea why dnf copr-enable does not use the correct rawhide repository, but a non existing fedora 30 repo.

Comment 2 Bruno Goncalves 2018-09-14 09:37:46 UTC
If I set VERSION="30 (Rawhide)" on /etc/os-release it works

# cat /etc/os-release 
NAME=Fedora
VERSION="30 (Rawhide)"
ID=fedora
VERSION_ID=30
PLATFORM_ID="platform:f30"
PRETTY_NAME="Fedora 30 (Cloud Edition)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:30"
HOME_URL="https://fedoraproject.org/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=rawhide
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=rawhide
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Cloud Edition"
VARIANT_ID=cloud


# dnf copr enable -y mvadkert/beakerlib-libraries
Repository successfully enabled.

Comment 3 Dusty Mabe 2018-09-14 14:05:26 UTC
not sure what the problem is exactly I found an old rawhide disk laying around and it shows the similar output from the f29 time frame  (this is atomic host):

```
[root@localhost ~]# rpm-ostree status
State: idle; auto updates disabled
Deployments:
● ostree://fedora:fedora/rawhide/x86_64/atomic-host
                   Version: Rawhide.20180308.n.2 (2018-03-08 10:42:30)                                 
                    Commit: 0dbb2ca20192b6dedf2965fb39e5cd680d31b5f596429a1da11344009ed5c353           
[root@localhost ~]#
[root@localhost ~]# cat /etc/os-release
NAME=Fedora
VERSION="29 (Atomic Host)"
ID=fedora
VERSION_ID=29
PRETTY_NAME="Fedora 29 (Atomic Host)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:29"
HOME_URL="https://fedoraproject.org/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"                            
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=rawhide
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=rawhide
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"                                
VARIANT="Atomic Host"
VARIANT_ID=atomic.host
[root@localhost ~]# rpm -q --provides fedora-release
config(fedora-release) = 29-0.1
fedora-release = 29-0.1
fedora-release-nonproduct = 29
fedora-release-standard = 22-0.8
redhat-release
system-release
system-release(29)

```

So that part looks fine.

I booted a rawhide cloud image from rawhide-cloud-base-20180820.n.3 and the `dnf copr enable` command doesn't blow up for me:

```
[root@vanilla-rawhide ~]# dnf copr enable -y mvadkert/beakerlib-libraries
Error: This repository does not have any builds yet so you cannot enable it now.
[root@vanilla-rawhide ~]# 
[root@vanilla-rawhide ~]# rpm -q dnf 
dnf-3.2.0-2.fc29.noarch

```

Comment 4 Dusty Mabe 2018-09-14 14:11:09 UTC
yep and just downloaded latest rawhide cloud image and I can see dnf blow up:

```
[root@vanilla-rawhide ~]# rpm -q dnf
dnf-3.5.1-1.fc30.noarch
[root@vanilla-rawhide ~]#
[root@vanilla-rawhide ~]# dnf copr enable -y mvadkert/beakerlib-libraries
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/dnf/util.py", line 128, in _urlopen
    libdnf.repo.Downloader.downloadURL(conf._config if conf else None, url, fo.fileno())
RuntimeError: Status code: 404 for https://copr.fedorainfracloud.org/coprs/mvadkert/beakerlib-libraries/repo/fedora-30/                                                                                          

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/dnf", line 58, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 179, in user_main
    errcode = main(args)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 64, in main
    return _main(base, args, cli_class, option_parser_class)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 99, in _main
    return cli_run(cli, base)
  File "/usr/lib/python3.7/site-packages/dnf/cli/main.py", line 115, in cli_run
    cli.run()
  File "/usr/lib/python3.7/site-packages/dnf/cli/cli.py", line 1049, in run
    return self.command.run()
  File "/usr/lib/python3.7/site-packages/dnf-plugins/copr.py", line 200, in run
    self._download_repo(project_name, repo_filename, chroot)
  File "/usr/lib/python3.7/site-packages/dnf-plugins/copr.py", line 339, in _download_repo
    f = self.base.urlopen(self.copr_url + api_path, mode='w+')
  File "/usr/lib/python3.7/site-packages/dnf/base.py", line 2311, in urlopen
    return dnf.util._urlopen(url, self.conf, repo, mode, **kwargs)
  File "/usr/lib/python3.7/site-packages/dnf/util.py", line 130, in _urlopen
    raise IOError(e.args[1])
IndexError: tuple index out of range

```

Comment 5 Miroslav Vadkerti 2018-09-14 19:13:26 UTC
Not sure why we are seeing this, but looking @ dnf copr plugin:

https://github.com/rpm-software-management/dnf-plugins-core/blob/ac2299980c8ae0012aa5f82a3bbe083ce27ac21a/plugins/copr.py#L308

    if "Rawhide" in dist:
        chroot = ("fedora-rawhide-x86_64")

It uses rawhide if it finds rawhide in dist, where dist is:

    from platform import linux_distribution
    linux_distribution()

I guess something has changed

Comment 6 Miroslav Vadkerti 2018-09-14 19:13:39 UTC
Not sure why we are seeing this, but looking @ dnf copr plugin:

https://github.com/rpm-software-management/dnf-plugins-core/blob/ac2299980c8ae0012aa5f82a3bbe083ce27ac21a/plugins/copr.py#L308

    if "Rawhide" in dist:
        chroot = ("fedora-rawhide-x86_64")

It uses rawhide if it finds rawhide in dist, where dist is:

    from platform import linux_distribution
    linux_distribution()

I guess something has changed

Comment 7 Jaroslav Mracek 2018-09-24 15:22:45 UTC
I hope that problem will be fixed soon.

Comment 8 Pavla Kratochvilova 2018-10-02 08:49:55 UTC
One of the issues in this bug, IndexError: tuple index out of range, should be fixed by this PR: https://github.com/rpm-software-management/dnf/pull/1225

Comment 9 Ben Cotton 2019-08-13 17:11:15 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to '31'.

Comment 10 Ben Cotton 2019-08-13 18:55:42 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 31 development cycle.
Changing version to 31.