janitor/ab-janitor: attempt initial clones until success

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>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Michael Halstead 2025-05-22 11:38:25 -07:00 committed by Richard Purdie
parent f9391839a5
commit 8c0742cac4

View File

@ -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)