From 40ce635164f7138e74cb63795cbe3c45a23cabee Mon Sep 17 00:00:00 2001 From: mprahl Date: Mar 20 2019 17:42:28 +0000 Subject: [PATCH 1/2] Keep the database session alive when checking the base module modulemd --- diff --git a/module_build_service/utils/general.py b/module_build_service/utils/general.py index b542e18..0fd13a9 100644 --- a/module_build_service/utils/general.py +++ b/module_build_service/utils/general.py @@ -258,18 +258,19 @@ def get_rpm_release(module_build): base_module_obj = models.ModuleBuild.get_build_from_nsvc( session, base_module, bm_in_xmd['stream'], bm_in_xmd['version'], bm_in_xmd['context']) - if not base_module_obj: - continue + if not base_module_obj: + continue - # Default to using the base module's stream, but if the base module has disttag_marking - # set in the xmd, use that instead - try: - marking = base_module_obj.mmd().get_xmd()['mbs']['disttag_marking'] - # We must check for a KeyError because a Variant object doesn't support the `get` method - except KeyError: - marking = base_module_obj.stream - base_module_marking = marking + '+' - break + # Default to using the base module's stream, but if the base module has + # disttag_marking set in the xmd, use that instead + try: + marking = base_module_obj.mmd().get_xmd()['mbs']['disttag_marking'] + # We must check for a KeyError because a Variant object doesn't support the `get` + # method + except KeyError: + marking = base_module_obj.stream + base_module_marking = marking + '+' + break else: log.warning('Module build {0} does not buildrequire a base module ({1})' .format(module_build.id, ' or '.join(conf.base_module_names))) From c65e1b0a537047970f5c9495da1eff3a3f11361c Mon Sep 17 00:00:00 2001 From: mprahl Date: Mar 20 2019 17:43:24 +0000 Subject: [PATCH 2/2] Log the exception when an invalid modulemd is encountered This will help us determine why a modulemd couldn't be parsed other than formatting issues. An example of this is if the database session becomes stale, the exception is not due to the modulemd being invalid. --- diff --git a/module_build_service/models.py b/module_build_service/models.py index 5da2dfa..8fa6a80 100644 --- a/module_build_service/models.py +++ b/module_build_service/models.py @@ -384,6 +384,7 @@ class ModuleBuild(MBSBase): mmd = Modulemd.Module().new_from_string(self.modulemd) mmd.upgrade() except Exception: + log.exception('An error occurred while trying to parse the modulemd') raise ValueError("Invalid modulemd") return mmd