From 2c476fded6167e8619a691db148ae16e6d6efb79 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Mon, 4 Dec 2023 10:18:47 -0800 Subject: [PATCH] Add a retry loop to fifloader load_templates often fails for no good reason - see https://progress.opensuse.org/issues/121378 . This makes fifloader retry 20 times on failure to mitigate the issue. Signed-off-by: Adam Williamson --- fifloader.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fifloader.py b/fifloader.py index de47a948..ea3ac0e1 100755 --- a/fifloader.py +++ b/fifloader.py @@ -340,7 +340,17 @@ def run(args): if args.update: loadargs.append('--update') loadargs.append('-') - subprocess.run(loadargs, input=json.dumps(out), text=True, check=True) + tries = 20 + while True: + ret = subprocess.run(loadargs, input=json.dumps(out), text=True, check=True) + if ret.returncode: + if tries: + print(f"loader failed! retrying ({tries} attempts remaining)") + tries -= 1 + else: + sys.exit("loader failed and all retries exhausted!") + else: + break def main(): """Main loop."""