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 <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2024-05-09 14:59:16 +08:00
parent bc0334cc09
commit 627b72597e
2 changed files with 14 additions and 2 deletions

View File

@ -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(

View File

@ -745,7 +745,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
@ -755,6 +757,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, [])