From 872320a230f8b1b1795f9794c773bd2878389c63 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: May 13 2021 15:05:35 +0000 Subject: [PATCH 1/2] use scm_stream instead of scm.branch --- diff --git a/module_build_service/common/submit.py b/module_build_service/common/submit.py index b0cf72e..8988776 100644 --- a/module_build_service/common/submit.py +++ b/module_build_service/common/submit.py @@ -102,11 +102,11 @@ def fetch_mmd(url, branch=None, allow_local_url=False, whitelist_url=False, mand if isinstance(stream_or_packager, Modulemd.ModuleStream): # this is a ModuleStreamV2 object stream_or_packager = stream_or_packager.copy(stream_or_packager.get_module_name(), - scm.branch) + scm_stream) else: # this is a PackagerV3 object stream_or_packager = stream_or_packager.copy() - stream_or_packager.set_stream_name(scm.branch) + stream_or_packager.set_stream_name(scm_stream) # If the version is in the modulemd, throw an exception since the version # since the version is generated by MBS From a8adfd4f7434cbea9e9f8bd032563889dd2c1c30 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: May 13 2021 15:36:53 +0000 Subject: [PATCH 2/2] defer commit of module entry until we set the context and validate --- diff --git a/module_build_service/common/models.py b/module_build_service/common/models.py index 398f1df..138cd15 100644 --- a/module_build_service/common/models.py +++ b/module_build_service/common/models.py @@ -621,6 +621,7 @@ class ModuleBuild(MBSBase): rebuild_strategy=None, scratch=False, srpms=None, + commit=True, **kwargs ): now = datetime.utcnow() @@ -650,7 +651,8 @@ class ModuleBuild(MBSBase): module.buildrequires.append(base_module) db_session.add(module) - db_session.commit() + if commit: + db_session.commit() return module def transition(self, db_session, conf, state, state_reason=None, failure_type="unspec"): diff --git a/module_build_service/web/submit.py b/module_build_service/web/submit.py index 963454e..b4343e1 100644 --- a/module_build_service/web/submit.py +++ b/module_build_service/web/submit.py @@ -701,6 +701,8 @@ def submit_module_build(db_session, username, stream_or_packager, params, module reused_module_id=params.get("reuse_components_from"), scratch=params.get("scratch"), srpms=params.get("srpms"), + # don't commit now, we do it ourselves below + commit=False, ) module.build_context, module.runtime_context, module.context, \ module.build_context_no_bms = module.contexts_from_mmd(module.modulemd)