Check dnf version before skipping base module conflicts

The base module conflict generation was skipped for local builds
in 6b2e5be93a because libdnf wasn't ported to libmodulemd yet -
that was done in libdnf-0.45, so only warn and skip for versions of
dnf too old to require libdnf-0.45.

(Don't just unconditionally skip check/warning in case someone is
doing local module builds on RHEL 8.)
This commit is contained in:
Owen W. Taylor
2020-10-29 11:23:06 -04:00
parent c66eca6044
commit 1f2fbca7d4
4 changed files with 21 additions and 11 deletions

View File

@@ -9,6 +9,7 @@ import tempfile
import dnf
import kobo.rpmlib
import koji
import packaging.version
import six.moves.xmlrpc_client as xmlrpclib
from module_build_service.common import conf, log, models, scm
@@ -216,7 +217,7 @@ def _get_rawhide_version():
return build_target["build_tag_name"].partition("-build")[0]
def handle_collisions_with_base_module_rpms(mmd, arches):
def handle_collisions_with_base_module_rpms(mmd, arches, force_for_old_dnf=False):
"""
Find any RPMs in the buildrequired base modules that collide with the buildrequired modules.
@@ -226,8 +227,22 @@ def handle_collisions_with_base_module_rpms(mmd, arches):
:param Modulemd.ModuleStream mmd: the modulemd to find the collisions
:param list arches: the arches to limit the external repo queries to
:param bool force_for_old_dnf: add the conflicts even if libdnf can't handle them
:raise RuntimeError: when a Koji query fails
"""
if (not force_for_old_dnf
and packaging.version.parse(dnf.VERSION) < packaging.version.parse('4.2.19')):
# For local builds, we can't use this code unless libdnf uses libmodulemd2
# (done in libdnf-0.45) - we can't check the libdnf version, so use
# dnf-4.2.19 (which requires libdnf-0.45) as a proxy.
log.warning(
"The necessary conflicts could not be generated due to RHBZ#1693683. "
"Some RPMs from the base modules (%s) may end up being used over modular RPMs. "
"This may result in different behavior than a production build.",
", ".join(conf.base_module_names)
)
return
log.info("Finding any buildrequired modules that collide with the RPMs in the base modules")
bm_tags = set()
non_bm_tags = set()

View File

@@ -207,15 +207,8 @@ def init(msg_id, module_build_id, module_build_state):
# Sets xmd["mbs"]["ursine_rpms"] with RPMs from the buildrequired base modules which
# conflict with the RPMs from other buildrequired modules. This is done to prefer modular
# RPMs over base module RPMs even if their NVR is lower.
if conf.system in ("koji", "test"):
handle_collisions_with_base_module_rpms(mmd, arches)
else:
log.warning(
"The necessary conflicts could not be generated due to RHBZ#1693683. "
"Some RPMs from the base modules (%s) may end up being used over modular RPMs. "
"This may result in different behavior than a production build.",
", ".join(conf.base_module_names)
)
handle_collisions_with_base_module_rpms(mmd, arches,
force_for_old_dnf=conf.system in ("koji", "test"))
mmd = record_filtered_rpms(mmd)
build.modulemd = mmd_to_str(mmd)

View File

@@ -13,6 +13,7 @@ koji
ldap3
moksha.hub
munch
packaging
prometheus_client
pygobject
pyOpenSSL

View File

@@ -291,7 +291,8 @@ def test_handle_collisions_with_base_module_rpms(mock_grft, mock_get_session):
}
mock_grft.side_effect = [bm_rpms, non_bm_rpms]
default_modules.handle_collisions_with_base_module_rpms(mmd, ["aarch64", "x86_64"])
default_modules.handle_collisions_with_base_module_rpms(mmd, ["aarch64", "x86_64"],
force_for_old_dnf=True)
mock_get_session.assert_called_once()
xmd_mbs = mmd.get_xmd()["mbs"]