mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-13 01:54:59 +08:00
Last tweak and fixes for async stuff.
This commit is contained in:
@@ -200,9 +200,13 @@ class KojiModuleBuilder(GenericBuilder):
|
||||
""" Returns True or False if the given artifacts are in the build root.
|
||||
"""
|
||||
assert self.module_target, "Invalid build target"
|
||||
|
||||
tag_id = self.module_target['build_tag']
|
||||
repo = self.koji_session.getRepo(tag_id)
|
||||
builds = [ self.koji_session.getBuild(a) for a in artifacts]
|
||||
builds = [self.koji_session.getBuild(a) for a in artifacts]
|
||||
log.info("%r checking buildroot readiness for "
|
||||
"repo: %r, tag_id: %r, artifacts: %r, builds: %r" % (
|
||||
self, repo, tag_id, artifacts, builds))
|
||||
return bool(koji.util.checkForBuilds(
|
||||
self.koji_session,
|
||||
tag_id,
|
||||
|
||||
@@ -263,6 +263,8 @@ class ComponentBuild(Base):
|
||||
task_id = Column(Integer) # This is the id of the build in koji
|
||||
# XXX: Consider making this a proper ENUM (or an int)
|
||||
state = Column(Integer)
|
||||
# This stays as None until the build completes.
|
||||
nvr = Column(String)
|
||||
|
||||
# A monotonically increasing integer that represents which batch or
|
||||
# iteration this *component* is currently in. This relates to the owning
|
||||
|
||||
@@ -40,13 +40,14 @@ def _finalize(config, session, msg, state):
|
||||
|
||||
# First, find our ModuleBuild associated with this repo, if any.
|
||||
component_build = rida.database.ComponentBuild.from_component_event(session, msg)
|
||||
nvr = "{name}-{version}-{release}".format(**msg['msg'])
|
||||
if not component_build:
|
||||
template = "We have no record of {name}-{version}-{release}"
|
||||
log.debug(template.format(**msg['msg']))
|
||||
log.debug("We have no record of %s" % nvr)
|
||||
return
|
||||
|
||||
# Mark the state in the db.
|
||||
component_build.state = state
|
||||
component_build.nvr = nvr
|
||||
session.commit()
|
||||
|
||||
parent = component_build.module_build
|
||||
@@ -58,14 +59,18 @@ def _finalize(config, session, msg, state):
|
||||
session.commit()
|
||||
return
|
||||
|
||||
# Otherwise.. if it didn't fail, then install the macros
|
||||
# TODO -- we should just do this with a koji target that feeds -build.
|
||||
# Otherwise.. if it didn't fail, then tag it.
|
||||
if state == koji.BUILD_STATES['COMPLETE']:
|
||||
# And install the macros.
|
||||
module_name = parent.name
|
||||
tag = parent.koji_tag
|
||||
builder = rida.builder.KojiModuleBuilder(module_name, config, tag_name=tag)
|
||||
builder.buildroot_resume()
|
||||
# tag && add to srpm-build group
|
||||
nvr = "{name}-{version}-{release}".format(**msg['msg'])
|
||||
builder.buildroot_add_artifacts([nvr,], install=True)
|
||||
install = bool(component_build.package == 'module-build-macros')
|
||||
builder.buildroot_add_artifacts([nvr,], install=install)
|
||||
session.commit()
|
||||
|
||||
# Find all of the sibling builds of this particular build.
|
||||
|
||||
@@ -36,11 +36,6 @@ log = logging.getLogger(__name__)
|
||||
def done(config, session, msg):
|
||||
""" Called whenever koji rebuilds a repo, any repo. """
|
||||
|
||||
# TODO -- working here.
|
||||
# finished the utilities for getting batch and starting next.
|
||||
# finished the simpler component-build event
|
||||
# need to write this stuff, the more complicated bits.
|
||||
|
||||
# First, find our ModuleBuild associated with this repo, if any.
|
||||
tag = msg['msg']['tag'].strip('-build')
|
||||
module_build = rida.database.ModuleBuild.from_repo_done_event(session, msg)
|
||||
@@ -86,7 +81,7 @@ def done(config, session, msg):
|
||||
|
||||
# Ok, for the subset of builds that did complete successfully, check to
|
||||
# see if they are in the buildroot.
|
||||
artifacts = [component_build.package for component_build in good]
|
||||
artifacts = [component_build.nvr for component_build in good]
|
||||
if not builder.buildroot_ready(artifacts):
|
||||
log.info("Not all of %r are in the buildroot. Waiting." % artifacts)
|
||||
return
|
||||
@@ -101,13 +96,14 @@ def done(config, session, msg):
|
||||
# or, if everything is built successfully, then we can bless the module as
|
||||
# complete.
|
||||
leftover_components = [
|
||||
c for c in module_build.components_builds
|
||||
c for c in module_build.component_builds
|
||||
if c.state != koji.BUILD_STATES['COMPLETE']
|
||||
]
|
||||
if leftover_components:
|
||||
rida.utils.start_next_build_batch(module_build, session, builder, components=leftover_components)
|
||||
rida.utils.start_next_build_batch(
|
||||
module_build, session, builder, components=leftover_components)
|
||||
else:
|
||||
module_build.transition(config, state=rida.BUILD_STATES['complete'])
|
||||
module_build.transition(config, state=rida.BUILD_STATES['done'])
|
||||
session.commit()
|
||||
|
||||
# And that's it. :)
|
||||
|
||||
Reference in New Issue
Block a user