mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 11:48:33 +08:00
Gracefully handle builds without a koji tag
MBS will iterate through all the builds in buildrequires to determine the expected list of arches on the associated Koji tag. In some cases, these builds do not have a Koji tag. They should be skipped for this operation. Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
This commit is contained in:
@@ -1336,6 +1336,9 @@ class KojiModuleBuilder(GenericBuilder):
|
||||
the module build in the build system.
|
||||
:return: list of architectures
|
||||
"""
|
||||
if not module.koji_tag:
|
||||
log.warning("No Koji tag associated with module %r", module)
|
||||
return []
|
||||
koji_session = KojiModuleBuilder.get_session(conf, login=False)
|
||||
tag = koji_session.getTag(module.koji_tag)
|
||||
if not tag:
|
||||
|
||||
@@ -943,15 +943,25 @@ class TestKojiBuilder:
|
||||
ret = KojiModuleBuilder.get_module_build_arches(module_build)
|
||||
assert ret == []
|
||||
|
||||
@patch.dict("sys.modules", krbV=MagicMock())
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.KojiClientSession")
|
||||
def test_get_module_build_arches_without_tag(self, ClientSession):
|
||||
module_build = module_build_service.models.ModuleBuild.get_by_id(db_session, 2)
|
||||
module_build.koji_tag = None
|
||||
session = ClientSession.return_value
|
||||
ret = KojiModuleBuilder.get_module_build_arches(module_build)
|
||||
assert ret == []
|
||||
session.getTag.assert_not_called()
|
||||
session.assert_not_called()
|
||||
|
||||
@patch.dict("sys.modules", krbV=MagicMock())
|
||||
@patch("module_build_service.builder.KojiModuleBuilder.KojiClientSession")
|
||||
def test_get_module_build_arches_with_unknown_tag(self, ClientSession):
|
||||
module_build = module_build_service.models.ModuleBuild.get_by_id(db_session, 2)
|
||||
session = ClientSession.return_value
|
||||
session.getTag.return_value = None
|
||||
with pytest.raises(ValueError) as exc_info:
|
||||
with pytest.raises(ValueError, match="Unknown Koji tag .*"):
|
||||
KojiModuleBuilder.get_module_build_arches(module_build)
|
||||
assert "Unknown Koji tag" in str(exc_info.value)
|
||||
|
||||
|
||||
class TestGetDistTagSRPM:
|
||||
|
||||
Reference in New Issue
Block a user