From bb4652b21d3b56e8a5dd36aba35886141f424b6b Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Dec 05 2024 17:13:19 +0000 Subject: Allow filtering the 'missing arch' list for containers (#43) Atomic desktop team would like us to ignore missing ppc64le containers when deciding whether to publish the multiarch manifest, because ppc64le build is broken and not easily fixable, and they don't think anyone is really using atomic desktop containers on ppc64le anyway. This implements that for the two desktops for which we actually (try to) build on ppc64le. It's done as code not config for now just because expressing this in config feels awkward and hopefully we won't need to change it much. Signed-off-by: Adam Williamson --- diff --git a/fedora-image-uploader/fedora_image_uploader/handler.py b/fedora-image-uploader/fedora_image_uploader/handler.py index ec092e4..b8092d6 100644 --- a/fedora-image-uploader/fedora_image_uploader/handler.py +++ b/fedora-image-uploader/fedora_image_uploader/handler.py @@ -295,6 +295,7 @@ class Uploader: firstregref = f"{firstreg}/{repo}:{maintag}" # ...but first, bail if any arches are missing missing = self._missing_manifest_arches(firstregref, builtarches) + missing = self._filter_missing(missing, repo, maintag) if missing: _log.warning( "Arches %s in current manifest %s were not built in compose %s, " @@ -344,6 +345,24 @@ class Uploader: return set() return set(arch for arch in currarches if arch not in builtarches) + def _filter_missing(self, missing: set, repo: str, maintag: str) -> set: + """Filter the missing list based on per-repo / per-tag rules.""" + rules = { + "fedora-silverblue": { + "*": ["ppc64le"], + }, + "fedora-kinoite": { + "*": ["ppc64le"], + }, + } + ok = set() + rule = rules.get(repo, {}) + if maintag in rule: + ok.update(rule[maintag]) + if "*" in rule: + ok.update(rule["*"]) + return missing.difference(ok) + def handle_container(self, image: dict, ffrel: ff_release.Release): """Handle container images.""" registries = self.conf["container"].get("registries") diff --git a/fedora-image-uploader/tests/test_handler.py b/fedora-image-uploader/tests/test_handler.py index b4af15d..ab9646a 100644 --- a/fedora-image-uploader/tests/test_handler.py +++ b/fedora-image-uploader/tests/test_handler.py @@ -328,6 +328,15 @@ def test_containers_missing(mock_subrun, caplog): assert caplog.records[-1].getMessage() == "Could not find or parse existing manifest mtest!" +def test_containers_filter_missing(): + """Tests for _filter_missing.""" + consumer = Uploader() + ret = consumer._filter_missing({"aarch64", "ppc64le"}, "fedora-silverblue", "42") + assert ret == {"aarch64"} + ret = consumer._filter_missing({"aarch64", "ppc64le"}, "fedora-minimal", "42") + assert ret == {"aarch64", "ppc64le"} + + @pytest.mark.vcr @mock.patch.dict(config.conf, {"consumer_config": {"container": {}}}) @mock.patch("subprocess.run")