diff --git a/module_build_service/builder.py b/module_build_service/builder.py index 20ed1b2e..79ee5547 100644 --- a/module_build_service/builder.py +++ b/module_build_service/builder.py @@ -1433,8 +1433,17 @@ mdpolicy=group:primary for name in os.listdir(resultsdir): shutil.copyfile(os.path.join(resultsdir, name), os.path.join(self.resultsdir, name)) - reason = "Built %s in Mock" % (artifact_name) - return build_id, state, reason, None + # We return BUILDING state here even when we know it is already + # completed or failed, because otherwise utils.start_build_batch + # would think this component is already built and also tagged, but + # we have just built it - tagging will happen as result of build + # change message we are sending above using _send_build_change. + # It is just to make this backend compatible with other backends, + # which return COMPLETE here only in case the resulting build is + # already in repository ready to be used. This is not a case for Mock + # backend in the time we return here. + reason = "Building %s in Mock" % (artifact_name) + return build_id, koji.BUILD_STATES['BUILDING'], reason, None def build(self, artifact_name, source): log.info("Starting building artifact %s: %s" % (artifact_name, source)) diff --git a/module_build_service/scheduler/handlers/components.py b/module_build_service/scheduler/handlers/components.py index c039b47b..e84d9fa2 100644 --- a/module_build_service/scheduler/handlers/components.py +++ b/module_build_service/scheduler/handlers/components.py @@ -99,8 +99,10 @@ def _finalize(config, session, msg, state): builder.buildroot_add_artifacts(built_components_in_batch, install=install) builder.tag_artifacts(built_components_in_batch) session.commit() - else: - # We have some unbuilt components in this batch. We might hit the + elif (not any([c.state == koji.BUILD_STATES['BUILDING'] + for c in unbuilt_components_in_batch])): + # We are not in the middle of the batch building and + # we have some unbuilt components in this batch. We might hit the # concurrent builds threshold in previous call of start_build_batch # done in repos.py:done(...), but because we have just finished one # build, try to call start_build_batch again so in case we hit the