From acf91a4e5403eb1193c05878f7eef35e0f659aa0 Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Fri, 10 Jul 2020 10:24:00 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=83=20Enable=20fastestmirror=20in=20dn?= =?UTF-8?q?f-json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- dnf-json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dnf-json b/dnf-json index cdc6b3cbc..652c4b6bc 100755 --- a/dnf-json +++ b/dnf-json @@ -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