From 932a4ffe24ba183cf70ac6008217e74c564d530e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Lehmann?= Date: Thu, 21 Aug 2025 11:51:08 +0200 Subject: [PATCH] Cache koji builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in order to decrease the load on koji. With what's currently in the pipe, we decrease the number of koji calls from 65 to 37 with the cache. Signed-off-by: Gaƫtan Lehmann --- scripts/pkg_in_pipe/pkg_in_pipe.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/pkg_in_pipe/pkg_in_pipe.py b/scripts/pkg_in_pipe/pkg_in_pipe.py index 1a9d516..8c0c5bb 100755 --- a/scripts/pkg_in_pipe/pkg_in_pipe.py +++ b/scripts/pkg_in_pipe/pkg_in_pipe.py @@ -209,7 +209,7 @@ def find_previous_build_commit(session, build_tag, build): ] if not tagged: return None - previous_build = session.getBuild(tagged[0]['build_id']) + previous_build = get_koji_build(session, tagged[0]['build_id']) if not previous_build.get('source'): return None return parse_source(previous_build['source'])[1] @@ -253,6 +253,14 @@ def find_pull_requests(gh, repo, start_sha, end_sha): prs.update(commit_prs) return sorted(prs, key=lambda p: p.number, reverse=True) +def get_koji_build(session, build_id) -> dict: + cache_key = f'koji-build-{build_id}' + if not args.re_cache and cache_key in CACHE: + return cast(dict, CACHE[cache_key]) + else: + build = session.getBuild(build_id) + CACHE.set(cache_key, build, expire=RETENTION_TIME) + return build started_at = datetime.now() @@ -328,7 +336,7 @@ def find_pull_requests(gh, repo, start_sha, end_sha): taggeds = (t for t in taggeds if t['package_name'] in args.packages or args.packages == []) taggeds = sorted(taggeds, key=lambda t: (tag_history[t['build_id']], t['build_id']), reverse=True) for tagged in taggeds: - build = session.getBuild(tagged['build_id']) + build = get_koji_build(session, tagged['build_id']) prs: list[PullRequest] = [] maintained_by = None previous_build_sha = find_previous_build_commit(session, tag, build)