critpath.py: output Rawhide data under both 'rawhide' and 'fXX'

Currently we write the data for Rawhide to rawhide.json and
rawhide.txt. This is how Bodhi expects to find it...so long as
the release in question *still is* Rawhide. But there's a timing
issue at branching: the release that was Rawhide suddenly no
longer is, and its branch name changes to fXX, so now Bodhi will
look for the critpath data as fXX.json or fXX.txt. From the time
the Bodhi branch name is changed until the first time critpath
generation runs after a Branched compose has completed and been
synced, Bodhi will no longer have critpath data for the release
and will consider all updates non-critpath, which is bad.

This should completely avoid the problem by just *always* writing
the Rawhide critpath data under both names, so at branching, until
we get 'correct' fresh critpath data for the newly-branched release
we will at least just apply the latest Rawhide critpath to it.

Having the numbered files when we don't need them shouldn't cause
any problems. And given the way this script is written it also
should never be possible for us to write Rawhide numbered files
over top of Branched numbered files. So I'm pretty sure it should
be safe to always do this.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2026-02-06 11:58:02 -08:00 • committed by Adam Williamson
commit 85ae9e2af3

View file

@ -284,44 +284,52 @@ def validate_args(args):
raise Exception("--with-coreos requires --srpm")
def write_files(critpath, outpath, jsonout):
def write_files(critpath, outpaths, jsonoutpaths):
# write JSON outputs first
wrapped = {"rpm": critpath}
with open(jsonout, mode="w", encoding="utf-8") as jsonoutfh:
json.dump(wrapped, jsonoutfh, sort_keys=True, indent=4)
print(f"Wrote grouped critpath data to {jsonout}")
if jsonout == "rawhide.json":
# kinda ugly hack so we get critpath data for ELN
# https://pagure.io/releng/issue/12303
elnfiltered = {
group: critpath[group] for group in critpath if f"@{group}" in ELN_CRITPATH_GROUPS
}
elnwrapped = {"rpm": elnfiltered}
with open("eln.json", mode="w", encoding="utf-8") as elnoutfh:
json.dump(elnwrapped, elnoutfh, sort_keys=True, indent=4)
print(f"Also wrote ELN-filtered grouped critpath data to eln.json")
elnfiltered = {}
for jsonout in jsonoutpaths:
with open(jsonout, mode="w", encoding="utf-8") as jsonoutfh:
json.dump(wrapped, jsonoutfh, sort_keys=True, indent=4)
print(f"Wrote grouped critpath data to {jsonout}")
if jsonout == "rawhide.json":
# kinda ugly hack so we get critpath data for ELN
# https://pagure.io/releng/issue/12303
elnfiltered = {
group: critpath[group] for group in critpath if f"@{group}" in ELN_CRITPATH_GROUPS
}
elnwrapped = {"rpm": elnfiltered}
with open("eln.json", mode="w", encoding="utf-8") as elnoutfh:
json.dump(elnwrapped, elnoutfh, sort_keys=True, indent=4)
print(f"Also wrote ELN-filtered grouped critpath data to eln.json")
# get a flat set of packages
pkgs = set()
for grppkgs in critpath.values():
pkgs = pkgs.union(set(grppkgs))
with open(outpath, mode="w", encoding="utf-8") as outfh:
for packagename in sorted(pkgs):
outfh.write(packagename + "\n")
package_count = len(pkgs)
outtext = f"Wrote {package_count} items to {outpath}"
if outpath == "rawhide.txt":
# kinda ugly hack so we get critpath data for ELN
# https://pagure.io/releng/issue/12303
elnpkgs = set()
for grppkgs in elnfiltered.values():
elnpkgs = elnpkgs.union(set(grppkgs))
with open("eln.txt", mode="w", encoding="utf-8") as elnoutfh:
for packagename in sorted(elnpkgs):
elnoutfh.write(packagename + "\n")
elnpkg_count = len(elnpkgs)
outtext += f" and {elnpkg_count} items to eln.txt"
print(outtext)
# write the text outputs
for outpath in outpaths:
with open(outpath, mode="w", encoding="utf-8") as outfh:
for packagename in sorted(pkgs):
outfh.write(packagename + "\n")
package_count = len(pkgs)
outtext = f"Wrote {package_count} items to {outpath}"
if outpath == "rawhide.txt":
# kinda ugly hack so we get critpath data for ELN
# https://pagure.io/releng/issue/12303
elnpkgs = set()
for grppkgs in elnfiltered.values():
elnpkgs = elnpkgs.union(set(grppkgs))
with open("eln.txt", mode="w", encoding="utf-8") as elnoutfh:
for packagename in sorted(elnpkgs):
elnoutfh.write(packagename + "\n")
elnpkg_count = len(elnpkgs)
outtext += f" and {elnpkg_count} items to eln.txt"
print(outtext)
def generate_critpath(release, args, output, jsonout, forcebranched=False):
def generate_critpath(release, args, outpaths, jsonoutpaths, forcebranched=False):
check_arches = args.arches.split(",")
alternate_check_arches = args.altarches.split(",")
package_count = 0
@ -370,7 +378,7 @@ def generate_critpath(release, args, output, jsonout, forcebranched=False):
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)
return generate_critpath(release, args, outpaths, jsonoutpaths, forcebranched=True)
if arch in alternate_check_arches:
print(f"Failed to retrieve repo data for alternate arch {arch}!")
continue
@ -398,7 +406,7 @@ def generate_critpath(release, args, output, jsonout, forcebranched=False):
for group in critpath:
critpath[group] = sorted(critpath[group])
write_files(critpath, output, jsonout)
write_files(critpath, outpaths, jsonoutpaths)
def main():
@ -411,11 +419,19 @@ def main():
print(f"Working on release {release}")
# the name expected by Bodhi is '[gitbranchname].json';
# for most releases this is 'f[relnum].json' but for
# Rawhide it is 'rawhide.json'
# Rawhide it is 'rawhide.json'. But for Rawhide we'll
# write *both* 'rawhide.' and 'f[relnum].' as it helps
# with branching:
# https://forge.fedoraproject.org/infra/docs/pulls/489#issuecomment-376451
prefixes = [f"f{release}"]
if relnums[release] == "rawhide":
generate_critpath(release, args, "rawhide.txt", "rawhide.json")
else:
generate_critpath(release, args, f"f{release}.txt", f"f{release}.json")
prefixes.append("rawhide")
generate_critpath(
release,
args,
[f"{p}.txt" for p in prefixes],
[f"{p}.json" for p in prefixes]
)
else:
generate_critpath(release, args, args.output, args.jsonout)