From 2fd3ab3c9c93110e71018681f9759eb166a639c9 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 18 Jun 2020 01:37:32 -0700 Subject: [PATCH] Fetching from urls: Error Message (#16434) * Fetching from urls: Error Message Fix the error message when fetching from consecutive `urls` of a package version. Each fail should show the currently failing URL, not the first url. Example multi-problem run that occured in real life: ``` ==> 5821: Installing util-macros curl: (28) Connection timed out after 10000 milliseconds curl: (16) Error in the HTTP2 framing layer curl: (22) The requested URL returned error: 403 Forbidden ==> Fetching https://www.x.org/archive/individual/util/util-macros-1.19.1.tar.bz2 ==> Failed to fetch file from URL: https://www.x.org/archive/individual/util/util-macros-1.19.1.tar.bz2 Curl failed with error 28 ==> Fetching https://mirrors.ircam.fr/pub/x.org/individual/util/util-macros-1.19.1.tar.bz2 ==> Failed to fetch file from URL: https://www.x.org/archive/individual/util/util-macros-1.19.1.tar.bz2 Curl failed with error 16 ==> Fetching http://xorg.mirrors.pair.com/individual/util/util-macros-1.19.1.tar.bz2 ==> Failed to fetch file from URL: https://www.x.org/archive/individual/util/util-macros-1.19.1.tar.bz2 URL https://www.x.org/archive/individual/util/util-macros-1.19.1.tar.bz2 was not found! ==> Fetching from https://www.x.org/archive/individual/util/util-macros-1.19.1.tar.bz2 failed. ==> Error: FetchError: All fetchers failed for spack-stage-util-macros-1.19.1-se2a2e74oyusj2r4esgcb7pr3qhh45ef ``` - `urls[0]`: HTTP2 layer error - `urls[1]`: timeout - `urls[2]`: missing file on mirror * x.org: two more mirrors x.org mirrors are a bit tricky, since many are out-of-sync or off. A good package to test with is `util-macros`, which had a "recent" release. --- lib/spack/spack/build_systems/xorg.py | 5 +++++ lib/spack/spack/fetch_strategy.py | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/spack/spack/build_systems/xorg.py b/lib/spack/spack/build_systems/xorg.py index 815bb7c26b..ae28b30929 100644 --- a/lib/spack/spack/build_systems/xorg.py +++ b/lib/spack/spack/build_systems/xorg.py @@ -14,9 +14,14 @@ class XorgPackage(spack.package.PackageBase): xorg_mirror_path = None #: List of x.org mirrors used by Spack + # Note: x.org mirrors are a bit tricky, since many are out-of-sync or off. + # A good package to test with is `util-macros`, which had a "recent" + # release. base_mirrors = [ 'https://www.x.org/archive/individual/', 'https://mirrors.ircam.fr/pub/x.org/individual/', + 'https://mirror.transip.net/xorg/individual/', + 'ftp://ftp.freedesktop.org/pub/xorg/individual/', 'http://xorg.mirrors.pair.com/individual/' ] diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py index c6200565e5..5f0cc4db5d 100644 --- a/lib/spack/spack/fetch_strategy.py +++ b/lib/spack/spack/fetch_strategy.py @@ -292,6 +292,7 @@ def fetch(self): tty.msg("Already downloaded %s" % self.archive_file) return + url = None for url in self.candidate_urls: try: partial_file, save_file = self._fetch_from_url(url) @@ -303,7 +304,7 @@ def fetch(self): pass if not self.archive_file: - raise FailedDownloadError(self.url) + raise FailedDownloadError(url) def _fetch_from_url(self, url): save_file = None @@ -369,12 +370,12 @@ def _fetch_from_url(self, url): if curl.returncode == 22: # This is a 404. Curl will print the error. raise FailedDownloadError( - self.url, "URL %s was not found!" % self.url) + url, "URL %s was not found!" % url) elif curl.returncode == 60: # This is a certificate error. Suggest spack -k raise FailedDownloadError( - self.url, + url, "Curl was unable to fetch due to invalid certificate. " "This is either an attack, or your cluster's SSL " "configuration is bad. If you believe your SSL " @@ -386,7 +387,7 @@ def _fetch_from_url(self, url): # This is some other curl error. Curl will print the # error, but print a spack message too raise FailedDownloadError( - self.url, + url, "Curl failed with error %d" % curl.returncode) # Check if we somehow got an HTML file rather than the archive we