From 70843952330106c09c95a8c78e16fe496930e29c Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Apr 21 2023 01:19:48 +0000 Subject: critpath.py: handle the 'release gap' problem There's this infamous issue with using release data from Bodhi (as this script does) - a new release is marked 'stable' in Bodhi several days before it's actually accessible in the normal location for 'stable' releases in the mirror system (even on dl.fp.o). If you just trust Bodhi to tell you when a release is stable and assume you can find it in the stable path, for a few days each cycle this will fail. I somehow failed to notice this would be a problem for critpath.py when adjusting it to use Bodhi data and be run daily, but...obviously it is: https://pagure.io/fedora-infrastructure/issue/11247 This is a somewhat hacky way to handle it, but it's quite easy and doesn't require too much change to the code. Signed-off-by: Adam Williamson --- diff --git a/scripts/critpath.py b/scripts/critpath.py index 7d3fb53..59586ca 100755 --- a/scripts/critpath.py +++ b/scripts/critpath.py @@ -81,20 +81,20 @@ def get_bodhi_releases(): return BODHIRELEASES -def get_paths(release): +def get_paths(release, forcebranched=False): """This does a certain amount of fudging so we can refer to Branched by its release number or "branched", and Rawhide by its release number or "rawhide" or "devel". """ relnums = get_bodhi_releases() - if relnums.get(release) == "stable": + if relnums.get(release) == "stable" and not forcebranched: return ( f"releases/{release}/Everything/$basearch/os", f"updates/{release}/Everything/$basearch" ) elif release in ("rawhide", "devel") or relnums.get(release) == "rawhide": return ("development/rawhide/Everything/$basearch/os", "") - elif release == "branched" or relnums.get(release) == "branched": + elif release == "branched" or relnums.get(release) == "branched" or forcebranched: if release == "branched": try: release = [relnum for relnum in relnums if relnums[relnum] == "branched"][0] @@ -267,7 +267,7 @@ def write_files(critpath, outpath, jsonout): print(f"Wrote {package_count} items to {outpath}") -def generate_critpath(release, args, output, jsonout): +def generate_critpath(release, args, output, jsonout, forcebranched=False): check_arches = args.arches.split(",") if not (release.isdigit() and int(release) < 37): # armhfp is gone on F37+ @@ -281,7 +281,7 @@ def generate_critpath(release, args, output, jsonout): baseurl = args.composeurl + "/Everything/$basearch/os" alturl = args.composeurl + "/Everything/$basearch/os" else: - paths = get_paths(release) + paths = get_paths(release, forcebranched=forcebranched) baseurl = args.url + paths[0] alturl = args.alturl + paths[0] if paths[1]: @@ -307,7 +307,20 @@ def generate_critpath(release, args, output, jsonout): urls = [url for url in urls if url] print(f"Expanding critical path for {arch}") - pkgdict = expand_dnf_critpath(urls, arch) + try: + pkgdict = expand_dnf_critpath(urls, arch) + except dnf.exceptions.RepoError: + # this is a dumb workaround for the 'interregnum problem' + # where for a few days each cycle a new release is marked + # stable in bodhi, but isn't actually in the stable path + # on the mirror yet. this should never recurse because + # releases/ isn't in the branched base URL, but just in + # case, check forcebranched too + if "releases/" in baseurl and not forcebranched: + print(f"Failed to find release {release} at stable path {baseurl}!") + print("Trying branched path instead...") + return generate_critpath(release, args, output, jsonout, forcebranched=True) + raise for (group, pkgs) in pkgdict.items(): package_count = len(pkgs)