mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-09 08:13:21 +08:00
Merge #147 Pass around more info on pre-built components
This commit is contained in:
@@ -549,7 +549,7 @@ chmod 644 %buildroot/%_rpmconfigdir/macros.d/macros.modules
|
||||
|
||||
if tagged:
|
||||
assert len(tagged) == 1, "Expected exactly one item in list. Got %s" % tagged
|
||||
return tagged[0]['task_id']
|
||||
return tagged[0]
|
||||
|
||||
return None
|
||||
|
||||
@@ -557,7 +557,7 @@ chmod 644 %buildroot/%_rpmconfigdir/macros.d/macros.modules
|
||||
"""
|
||||
:param source : scmurl to spec repository
|
||||
: param artifact_name: name of artifact (which we couldn't get from spec due involved macros)
|
||||
:return koji build task id
|
||||
:return 4-tuple of the form (koji build task id, state, reason, nvr)
|
||||
"""
|
||||
|
||||
# This code supposes that artifact_name can be built within the component
|
||||
@@ -580,11 +580,12 @@ chmod 644 %buildroot/%_rpmconfigdir/macros.d/macros.modules
|
||||
raise RuntimeError("Buildroot is not prep-ed")
|
||||
|
||||
# Skip existing builds
|
||||
task_id = self._get_task_by_artifact(artifact_name)
|
||||
task_info = self._get_task_by_artifact(artifact_name)
|
||||
task_id = task_info['task_id']
|
||||
if task_id:
|
||||
log.info("skipping build of %s. Build already exists (task_id=%s), via %s" % (
|
||||
source, task_id, self))
|
||||
return task_id
|
||||
return task_id, koji.BUILD_STATES['COMPLETE'], 'Build already exists.', task_info['nvr']
|
||||
|
||||
self._koji_whitelist_packages([artifact_name,])
|
||||
if '://' not in source:
|
||||
@@ -598,7 +599,13 @@ chmod 644 %buildroot/%_rpmconfigdir/macros.d/macros.modules
|
||||
priority=self.build_priority)
|
||||
log.info("submitted build of %s (task_id=%s), via %s" % (
|
||||
source, task_id, self))
|
||||
return task_id
|
||||
if task_id:
|
||||
state = koji.BUILD_STATES['BUILDING']
|
||||
reason = "Submitted %s to Koji" % (artifact_name)
|
||||
else:
|
||||
state = koji.BUILD_STATES['FAILED']
|
||||
reason = "Failed to submit artifact %s to Koji" % (artifact_name)
|
||||
return task_id, state, reason, None
|
||||
|
||||
@classmethod
|
||||
def tag_to_repo(cls, config, tag_name, arch):
|
||||
|
||||
@@ -27,6 +27,7 @@ from module_build_service import models, log
|
||||
import module_build_service.builder
|
||||
import module_build_service.pdc
|
||||
import module_build_service.utils
|
||||
import module_build_service.messaging
|
||||
|
||||
import koji
|
||||
|
||||
@@ -130,15 +131,7 @@ def wait(config, session, msg):
|
||||
build.batch = 1
|
||||
|
||||
artifact_name = "module-build-macros"
|
||||
state = koji.BUILD_STATES['BUILDING'] # Default state
|
||||
state_reason = ""
|
||||
task_id = builder.build(artifact_name=artifact_name, source=srpm)
|
||||
|
||||
# Fail task if we failed to submit it to koji
|
||||
# This typically happens when koji auth failed
|
||||
if not task_id:
|
||||
state = koji.BUILD_STATES['FAILED']
|
||||
state_reason = "Failed to submit artifact %s to Koji" % (artifact_name)
|
||||
task_id, state, reason, nvr = builder.build(artifact_name=artifact_name, source=srpm)
|
||||
|
||||
component_build = models.ComponentBuild(
|
||||
module_id=build.id,
|
||||
@@ -147,9 +140,16 @@ def wait(config, session, msg):
|
||||
scmurl=srpm,
|
||||
task_id=task_id,
|
||||
state=state,
|
||||
state_reason = state_reason,
|
||||
state_reason=reason,
|
||||
nvr=nvr,
|
||||
batch=1,
|
||||
)
|
||||
session.add(component_build)
|
||||
build.transition(config, state="build")
|
||||
session.add(build)
|
||||
session.commit()
|
||||
|
||||
# If this build already exists and is done, then fake the repo change event
|
||||
# back to the scheduler
|
||||
if state == koji.BUILD_STATES['COMPLETE']:
|
||||
return [module_build_service.messaging.KojiRepoChange('fake msg', build.koji_tag)]
|
||||
|
||||
@@ -70,11 +70,9 @@ def start_next_build_batch(config, module, session, builder, components=None):
|
||||
module.batch += 1
|
||||
for c in unbuilt_components:
|
||||
c.batch = module.batch
|
||||
c.task_id = builder.build(artifact_name=c.package, source=c.scmurl)
|
||||
c.task_id, c.state, c.state_reason, c.nvr = builder.build(artifact_name=c.package, source=c.scmurl)
|
||||
|
||||
if not c.task_id:
|
||||
c.state = koji.BUILD_STATES["FAILED"]
|
||||
c.state_reason = "Failed to submit to Koji"
|
||||
module.transition(config, models.BUILD_STATES["failed"],
|
||||
"Failed to submit artifact %s to Koji" % (c.package))
|
||||
session.add(module)
|
||||
|
||||
Reference in New Issue
Block a user