diff mbox series

[yocto-autobuilder-helper] scripts/yocto-supported-distros: catch intermittent HTTPError

Message ID 20250311-yocto-supported-distros-fixes-v1-1-eb6d143daab3@bootlin.com
State New
Headers show
Series [yocto-autobuilder-helper] scripts/yocto-supported-distros: catch intermittent HTTPError | expand

Commit Message

Antonin Godard March 11, 2025, 8:22 a.m. UTC
From: Antonin Godard <antonin.godard@bootlin.com>

Print a warning when we get an HTTPError and exit with 0. This can
happen intermittently and there isn't much we can do about it. For
example:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/29/builds/1158/steps/16/logs/stdio

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 scripts/yocto-supported-distros | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)


---
base-commit: 38784f58056d8d0b5000463a611bce5e31aa076f
change-id: 20250311-yocto-supported-distros-fixes-b9be6bdfa801

Best regards,
diff mbox series

Patch

diff --git a/scripts/yocto-supported-distros b/scripts/yocto-supported-distros
index db9928f..0cc314b 100755
--- a/scripts/yocto-supported-distros
+++ b/scripts/yocto-supported-distros
@@ -48,6 +48,7 @@  import tempfile
 
 from pathlib import Path
 from typing import List, Dict, Set
+from urllib.error import HTTPError
 
 
 CONFIG_REMOTE_URL = "https://git.yoctoproject.org/yocto-autobuilder2/plain/config.py"
@@ -250,12 +251,18 @@  def main():
         exit(1)
 
     if args.config_from_web:
-        with urllib.request.urlopen(CONFIG_REMOTE_URL) as r:
-            with tempfile.TemporaryDirectory() as tempdir:
-                with open(Path(tempdir) / "config.py", "wb") as conf:
-                    conf.write(r.read())
-                sys.path.append(tempdir)
-                import config
+        try:
+            with urllib.request.urlopen(CONFIG_REMOTE_URL) as r:
+                with tempfile.TemporaryDirectory() as tempdir:
+                    with open(Path(tempdir) / "config.py", "wb") as conf:
+                        conf.write(r.read())
+                    sys.path.append(tempdir)
+                    import config
+        except HTTPError as e:
+            print(f"WARNING: HTTPError when trying to fetch the config.py file from {CONFIG_REMOTE_URL}:")
+            print(e)
+            print("Safely exiting...")
+            exit(0)
     else:
         sys.path.append(os.path.dirname(args.config))
         import config