🏃 Enable fastestmirror in dnf-json

The time it takes to depsolve a blueprint varies widely depending on
where the job is running and which mirrors are randomly chosen based on
the data returned in the metalink XML.

Use dnf's fastestmirror plugin to choose the fastest mirror for
downloading metadata. This returns consistent results in PSI + AWS and
every depsolve completed in under 60 seconds after 25 tests in each
cloud.

Fixes #845.

Signed-off-by: Major Hayden <major@redhat.com>
This commit is contained in:
Major Hayden 2020-07-10 10:24:00 -05:00 committed by Major Hayden
parent d02e77de06
commit acf91a4e54

View file

@ -52,6 +52,18 @@ def dnfrepo(desc, parent_conf=None):
def create_base(repos, module_platform_id, persistdir, cachedir, arch):
base = dnf.Base()
# Enable fastestmirror to ensure we choose the fastest mirrors for
# downloading metadata (when depsolving) and downloading packages.
base.conf.fastestmirror = True
# Initialize all plugins (including fastestmirror).
base.init_plugins()
# Try another mirror if it takes longer than 5 seconds to connect.
base.conf.timeout = 5
# Set the rest of the dnf configuration.
base.conf.module_platform_id = module_platform_id
base.conf.config_file_path = "/dev/null"
base.conf.persistdir = persistdir