From 9d6226b4365c4960d485f64524eac545e7cb5355 Mon Sep 17 00:00:00 2001 From: Haibo Lin Date: Thu, 9 May 2024 14:59:16 +0800 Subject: [PATCH] pkgset: Avoid adding modules to unavailable arches If a module is not built for specific arches, pungi will skip adding it to these arches in pkgset phase. JIRA: RHELCMP-13625 Signed-off-by: Haibo Lin (cherry picked from commit 627b72597ef0ce2936053ab70e7c2e5c94ca4d2b) --- pungi/phases/pkgset/sources/source_koji.py | 11 ++++++++++- tests/test_pkgset_source_koji.py | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pungi/phases/pkgset/sources/source_koji.py b/pungi/phases/pkgset/sources/source_koji.py index 18c6746d..69f09261 100644 --- a/pungi/phases/pkgset/sources/source_koji.py +++ b/pungi/phases/pkgset/sources/source_koji.py @@ -222,6 +222,7 @@ def _add_module_to_variant( """ mmds = {} archives = koji_wrapper.koji_proxy.listArchives(build["id"]) + available_arches = set() for archive in archives: if archive["btype"] != "module": # Skip non module archives @@ -235,7 +236,9 @@ def _add_module_to_variant( # in basearch. This assumes that each arch in the build maps to a # unique basearch. _, arch, _ = filename.split(".") - filename = "modulemd.%s.txt" % getBaseArch(arch) + basearch = getBaseArch(arch) + filename = "modulemd.%s.txt" % basearch + available_arches.add(basearch) except ValueError: pass mmds[filename] = file_path @@ -260,6 +263,12 @@ def _add_module_to_variant( compose.log_debug("Module %s is filtered from %s.%s", nsvc, variant, arch) continue + if arch not in available_arches: + compose.log_debug( + "Module %s is not available for arch %s.%s", nsvc, variant, arch + ) + continue + filename = "modulemd.%s.txt" % arch if filename not in mmds: raise RuntimeError( diff --git a/tests/test_pkgset_source_koji.py b/tests/test_pkgset_source_koji.py index 385db314..0e55481d 100644 --- a/tests/test_pkgset_source_koji.py +++ b/tests/test_pkgset_source_koji.py @@ -741,7 +741,9 @@ class TestAddModuleToVariant(helpers.PungiTestCase): } def test_adding_module(self): - variant = mock.Mock(arches=["armhfp", "x86_64"], arch_mmds={}, modules=[]) + variant = mock.Mock( + arches=["armhfp", "x86_64", "ppc64le"], arch_mmds={}, modules=[] + ) source_koji._add_module_to_variant( self.koji, variant, self.buildinfo, compose=self.compose @@ -751,6 +753,7 @@ class TestAddModuleToVariant(helpers.PungiTestCase): self.assertEqual(mod1.get_NSVCA(), "module:master:20190318:abcdef:armhfp") mod2 = variant.arch_mmds["x86_64"]["module:master:20190318:abcdef"] self.assertEqual(mod2.get_NSVCA(), "module:master:20190318:abcdef:x86_64") + self.assertNotIn("ppc64le", variant.arch_mmds) self.assertEqual(len(variant.arch_mmds), 2) self.assertEqual(variant.modules, [])