From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>
Subject: [PATCH v2 3/3] tests/functional: handle URLError when fetching assets
Date: Fri, 29 Aug 2025 15:26:16 +0100 [thread overview]
Message-ID: <20250829142616.2633254-4-berrange@redhat.com> (raw)
In-Reply-To: <20250829142616.2633254-1-berrange@redhat.com>
We treat most HTTP errors as non-fatal when fetching assets,
but forgot to handle network level errors. This adds catching
of URLError so that we retry on failure, and will ultimately
trigger graceful skipping in the pre-cache task.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
tests/functional/qemu_test/asset.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tests/functional/qemu_test/asset.py b/tests/functional/qemu_test/asset.py
index 5c74adf224..2dd32bf28d 100644
--- a/tests/functional/qemu_test/asset.py
+++ b/tests/functional/qemu_test/asset.py
@@ -15,7 +15,7 @@
from time import sleep
from pathlib import Path
from shutil import copyfileobj
-from urllib.error import HTTPError
+from urllib.error import HTTPError, URLError
class AssetError(Exception):
def __init__(self, asset, msg, transient=False):
@@ -171,6 +171,14 @@ def fetch(self):
raise AssetError(self, "Unable to download: "
"HTTP error %d" % e.code)
continue
+ except URLError as e:
+ # This is typically a network/service level error
+ # eg urlopen error [Errno 110] Connection timed out>
+ tmp_cache_file.unlink()
+ self.log.error("Unable to download %s: URL error %s",
+ self.url, e.reason)
+ raise AssetError(self, "Unable to download: URL error %s" %
+ e.reason, transient=True)
except Exception as e:
tmp_cache_file.unlink()
raise AssetError(self, "Unable to download: %s" % e)
--
2.50.1
next prev parent reply other threads:[~2025-08-30 15:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 14:26 [PATCH v2 0/3] tests/functional: improve handling flaky downloads Daniel P. Berrangé
2025-08-29 14:26 ` [PATCH v2 1/3] tests/functional: enable force refresh of cached assets Daniel P. Berrangé
2025-08-29 21:16 ` Richard Henderson
2025-08-29 14:26 ` [PATCH v2 2/3] tests/functional: fix formatting of exception args Daniel P. Berrangé
2025-08-29 15:03 ` Thomas Huth
2025-08-29 21:19 ` Richard Henderson
2025-08-29 14:26 ` Daniel P. Berrangé [this message]
2025-08-29 15:03 ` [PATCH v2 3/3] tests/functional: handle URLError when fetching assets Thomas Huth
2025-08-29 21:21 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250829142616.2633254-4-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).