Make the DNF minrate setting configurable when loading repos

This commit is contained in:
mprahl
2019-10-01 10:00:12 -04:00
parent 2796b9e6a1
commit 164f592c1d
3 changed files with 15 additions and 3 deletions

View File

@@ -689,6 +689,13 @@ class Config(object):
"default": "master",
"desc": "Denotes the branch used for rawhide.",
},
"dnf_minrate": {
"type": int,
"default": 1024 * 100, # 100KB
"desc": "The minrate configuration on a DNF repo. This configuration will cause DNF to "
"timeout loading a repo if the download speed is below minrate for the "
"duration of the timeout."
}
}
def __init__(self, conf_section_obj):

View File

@@ -362,7 +362,9 @@ def _get_rpms_in_external_repo(repo_url, arches, cache_dir_name):
canon_arch = koji.canonArch(arch)
repo_name = "repo_{}".format(canon_arch)
repo_arch_url = repo_url.replace("$arch", canon_arch)
base.repos.add_new_repo(repo_name, dnf_conf, baseurl=[repo_arch_url])
base.repos.add_new_repo(
repo_name, dnf_conf, baseurl=[repo_arch_url], minrate=conf.dnf_minrate,
)
try:
# Load the repos in parallel

View File

@@ -419,8 +419,11 @@ def test_get_rpms_in_external_repo(mock_makedirs, mock_dnf_base):
# Test that i686 is mapped to i386 using the koji.canonArch().
mock_dnf_base.return_value.repos.add_new_repo.assert_called_with(
'repo_i386', mock_dnf_base.return_value.conf,
baseurl=['http://domain.local/repo/latest/i386/'])
"repo_i386",
mock_dnf_base.return_value.conf,
baseurl=["http://domain.local/repo/latest/i386/"],
minrate=conf.dnf_minrate,
)
def test_get_rpms_in_external_repo_invalid_repo_url():