Pass koji_tag to get_built_rpms_in_module_build()

For local builds, required modules are not necessarily in the local
database, so the method of looking up the build to find the koji tag
doesn't work reliably. However, the caller has the koji_tag - so just
pass it in.
This commit is contained in:
Owen W. Taylor
2020-12-07 11:56:27 -05:00
committed by breilly
parent e974aca48e
commit 35086174ba
7 changed files with 17 additions and 24 deletions

View File

@@ -31,7 +31,6 @@ from module_build_service.common.koji import (
)
from module_build_service.common.retry import retry
from module_build_service.scheduler import events
from module_build_service.scheduler.db_session import db_session
from module_build_service.scheduler.reuse import get_reusable_components, get_reusable_module
logging.basicConfig(level=logging.DEBUG)
@@ -1167,20 +1166,14 @@ class KojiModuleBuilder(GenericBuilder):
return weights
@classmethod
def get_built_rpms_in_module_build(cls, mmd):
def get_built_rpms_in_module_build(cls, mmd, koji_tag):
"""
:param Modulemd mmd: Modulemd to get the built RPMs from.
:koji_tag str: koji_tag corresponding to the module
:return: list of NVRs
"""
build = models.ModuleBuild.get_build_from_nsvc(
db_session,
mmd.get_module_name(),
mmd.get_stream_name(),
mmd.get_version(),
mmd.get_context()
)
koji_session = get_session(conf, login=False)
rpms = koji_session.listTaggedRPMS(build.koji_tag, latest=True)[0]
rpms = koji_session.listTaggedRPMS(koji_tag, latest=True)[0]
nvrs = set(kobo.rpmlib.make_nvr(rpm, force_epoch=True) for rpm in rpms)
return list(nvrs)

View File

@@ -753,24 +753,17 @@ class MockModuleBuilder(GenericBuilder):
self._createrepo(include_module_yaml=True)
@classmethod
def get_built_rpms_in_module_build(cls, mmd):
def get_built_rpms_in_module_build(cls, mmd, koji_tag):
"""
:param Modulemd mmd: Modulemd to get the built RPMs from.
:return: list of NVRs
"""
build = models.ModuleBuild.get_build_from_nsvc(
db_session,
mmd.get_module_name(),
mmd.get_stream_name(),
mmd.get_version(),
mmd.get_context()
)
if build.koji_tag.startswith("repofile://"):
if koji_tag.startswith("repofile://"):
# Modules from local repository have already the RPMs filled in mmd.
return mmd.get_rpm_artifacts()
else:
koji_session = get_session(conf, login=False)
rpms = koji_session.listTaggedRPMS(build.koji_tag, latest=True)[0]
rpms = koji_session.listTaggedRPMS(koji_tag, latest=True)[0]
nvrs = set(kobo.rpmlib.make_nvr(rpm, force_epoch=True) for rpm in rpms)
return list(nvrs)

View File

@@ -346,9 +346,10 @@ class GenericBuilder(six.with_metaclass(ABCMeta)):
raise NotImplementedError()
@classmethod
def get_built_rpms_in_module_build(cls, mmd):
def get_built_rpms_in_module_build(cls, mmd, koji_tag):
"""
:param Modulemd mmd: Modulemd to get the built RPMs from.
:koji_tag str: koji_tag corresponding to the module
:return: list of NVRs
"""
raise NotImplementedError()

View File

@@ -200,7 +200,7 @@ def record_filtered_rpms(mmd):
filtered_rpms = []
rpm_filter = req_mmd.get_rpm_filters()
if rpm_filter:
built_nvrs = builder.get_built_rpms_in_module_build(req_mmd)
built_nvrs = builder.get_built_rpms_in_module_build(req_mmd, req_data["koji_tag"])
for nvr in built_nvrs:
parsed_nvr = kobo.rpmlib.parse_nvr(nvr)
if parsed_nvr["name"] in rpm_filter: