diff mbox series

[yocto-autobuilder-helper] janitor/ab-janitor: attempt initial clones until success

Message ID 20250522183825.15315-1-mhalstead@linuxfoundation.org
State New
Headers show
Series [yocto-autobuilder-helper] janitor/ab-janitor: attempt initial clones until success | expand

Commit Message

Michael Halstead May 22, 2025, 6:38 p.m. UTC
If the git clone operations don't succeed the mirror_processor thread
will spin updating nothing and index builds will fail. Instead the
thread will attempt the clones as many times as needed logging each
failure.

These are bare mirrors so look for the refs dir instead of .git.

Signed-off-by: Michael Halstead <mhalstead@linuxfoundation.org>
---
 janitor/ab-janitor | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/janitor/ab-janitor b/janitor/ab-janitor
index bb58390..57749d6 100755
--- a/janitor/ab-janitor
+++ b/janitor/ab-janitor
@@ -65,8 +65,12 @@  def mirror_processor(mirrordir):
         mirror = ourconfig["repo-defaults"][repo]["url"]
         mirrorpath = os.path.join(mirrordir, repo)
         mirrorpaths.append(mirrorpath)
-        if not os.path.exists(mirrorpaths[-1] + "/.git/"):
-            os.system("git clone --bare --mirror %s %s" % (mirror, mirrorpaths[-1]))
+        while not os.path.exists(mirrorpath + "/refs"):
+            exit_code = os.system("git clone --bare --mirror %s %s" % (mirror, mirrorpath))
+            if exit_code == 0:
+                break
+            print("Failed to clone %s. Retrying in 30 seconds..." % mirror)
+            time.sleep(30)
     while True:
         for path in mirrorpaths:
             os.chdir(path)