Fix runtime stats reporting for noop job

The noop job currently tries to report runtime stats before adding it
to the buildset which triggers an exception [1]. Fix that by adding
the build to the buildset earlier.

[1] Trace:
2018-01-24 15:50:09,533 ERROR zuul.Scheduler: Exception reporting runtime stats
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/zuul/scheduler.py", line 374, in onBuildCompleted
    if self.statsd and build.pipeline:
  File "/usr/lib/python3.6/site-packages/zuul/model.py", line 1266, in pipeline
    return self.build_set.item.pipeline
AttributeError: 'NoneType' object has no attribute 'item'.

Change-Id: I88e9fd1c7623760be23597c82ebfb09faef54afb
This commit is contained in:
Tobias Henkel 2018-01-24 16:47:34 +01:00
parent 527e03ca94
commit 95e3d6fdac
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
2 changed files with 5 additions and 4 deletions

View File

@ -273,6 +273,10 @@ class ExecutorClient(object):
build.parameters = params
build.nodeset = nodeset
self.log.debug("Adding build %s of job %s to item %s" %
(build, job, item))
item.addBuild(build)
if job.name == 'noop':
self.sched.onBuildStarted(build)
self.sched.onBuildCompleted(build, 'SUCCESS', {})

View File

@ -392,13 +392,10 @@ class PipelineManager(object):
try:
nodeset = item.current_build_set.getJobNodeSet(job.name)
self.sched.nodepool.useNodeSet(nodeset)
build = self.sched.executor.execute(
self.sched.executor.execute(
job, item, self.pipeline,
build_set.dependent_changes,
build_set.merger_items)
self.log.debug("Adding build %s of job %s to item %s" %
(build, job, item))
item.addBuild(build)
except Exception:
self.log.exception("Exception while executing job %s "
"for change %s:" % (job, item.change))