From bcbaf2cf61659f1d0a59b666f0773c55eb20362e Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Fri, 29 Jul 2016 12:15:02 -0400 Subject: [PATCH] kill the wait statements. --- rida/scheduler/handlers/components.py | 13 ++++++++++++- rida/scheduler/handlers/modules.py | 26 +++++++++++++++----------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/rida/scheduler/handlers/components.py b/rida/scheduler/handlers/components.py index d81b5224..9e47233a 100644 --- a/rida/scheduler/handlers/components.py +++ b/rida/scheduler/handlers/components.py @@ -34,6 +34,7 @@ import koji logging.basicConfig(level=logging.DEBUG) log = logging.getLogger(__name__) + def _finalize(config, session, msg, state): """ Called whenever a koji build completes or fails. """ @@ -48,12 +49,21 @@ def _finalize(config, session, msg, state): component_build.state = state session.commit() + if component_build.package == 'module-build-macros': + module_name = component_build.module_build.name + tag = component_build.module_build.koji_tag + builder = rida.builder.KojiModuleBuilder(module_name, config, tag_name=tag) + # tag && add to srpm-build group + builder.buildroot_add_artifacts([component_build.package,], install=True) + session.commit() + # Find all of the sibling builds of this particular build. parent = component_build.module_build siblings = parent.component_builds # Are any of them still executing? - if any([c.state == koji.BUILD_STATES['BUILDING'] for c in siblings]): + premature = (koji.BUILD_STATES['BUILDING'], None) + if any([c.state in premature for c in siblings]): # Then they're not all done yet... continue to wait return @@ -66,6 +76,7 @@ def _finalize(config, session, msg, state): # Otherwise.. if all of the builds succeeded, then mark the module as good. parent.transition(config, rida.BUILD_STATES['done']) + session.commit() def complete(config, session, msg): diff --git a/rida/scheduler/handlers/modules.py b/rida/scheduler/handlers/modules.py index 34b94642..293784af 100644 --- a/rida/scheduler/handlers/modules.py +++ b/rida/scheduler/handlers/modules.py @@ -26,6 +26,9 @@ import rida.builder import rida.database import rida.pdc + +import koji + import logging import os @@ -77,16 +80,17 @@ def wait(config, session, msg): builder.buildroot_add_dependency(dependencies) # inject dist-tag into buildroot srpm = builder.get_disttag_srpm(disttag=".%s" % get_rpm_release_from_tag(tag)) - task_id = builder.build(artifact_name="module-build-macros", source=srpm) - # TODO -- this has to go eventually.. otherwise, we can only build one - # module at a time and that just won't scale. - builder.wait_task(task_id) - # TODO -- do cleanup if this fails - - artifact = get_artifact_from_srpm(srpm) - builder.buildroot_add_artifacts([artifact,], install=True) # tag && add to srpm-build group - builder.buildroot_ready(artifacts=[artifact,]) - - build.transition(config, state="build") # Wait for the buildroot to be ready. + artifact_name = "module-build-macros" + task_id = builder.build(artifact_name=artifact_name, source=srpm) + component_build = rida.database.ComponentBuild( + module_id=build.id, + package=artifact_name, + format="rpms", + scmurl=srpm, + task_id=task_id, + state = koji.BUILD_STATES['BUILDING'], + ) + session.add(component_build) + build.transition(config, state="build") session.commit()