Make buildset mandatory on build

With the introduction of type checking, many of the Optional attributes
must be checked in various places before accessing. Making the buildset
mandatory on the build removes some of those otherwise necessary
NoneType checks and will avoid more in future changes.

Change-Id: I70409551f0f786ad6ea9c4f2cf0ab0f9eb2d1555
This commit is contained in:
Felix Edel 2021-01-13 09:19:44 +01:00
parent f924716f09
commit 9674806662
3 changed files with 13 additions and 9 deletions

View File

@ -154,7 +154,12 @@ class ExecutorClient(object):
# TODO: deprecate and remove this variable?
params["zuul"]["_inheritance_path"] = list(job.inheritance_path)
build = Build(job, uuid, zuul_event_id=item.event.zuul_event_id)
build = Build(
job,
item.current_build_set,
uuid,
zuul_event_id=item.event.zuul_event_id,
)
build.parameters = params
build.nodeset = nodeset

View File

@ -1946,14 +1946,14 @@ class Build(object):
Job (related builds are grouped together in a BuildSet).
"""
def __init__(self, job, uuid, zuul_event_id=None):
def __init__(self, job, build_set, uuid, zuul_event_id=None):
self.job = job
self.build_set = build_set
self.uuid = uuid
self.url = None
self.result = None
self.result_data = {}
self.error_detail = None
self.build_set = None
self.execute_time = time.time()
self.start_time = None
self.end_time = None
@ -2140,7 +2140,6 @@ class BuildSet(object):
self.builds[build.job.name] = build
if build.job.name not in self.tries:
self.tries[build.job.name] = 1
build.build_set = self
def addRetryBuild(self, build):
self.retry_builds.setdefault(build.job.name, []).append(build)
@ -2645,7 +2644,7 @@ class QueueItem(object):
job.updateArtifactData(data)
except RequirementsError as e:
self.warning(str(e))
fakebuild = Build(job, None)
fakebuild = Build(job, self.current_build_set, None)
fakebuild.result = 'FAILURE'
self.addBuild(fakebuild)
self.setResult(fakebuild)
@ -2856,12 +2855,12 @@ class QueueItem(object):
for job in skipped:
child_build = self.current_build_set.getBuild(job.name)
if not child_build:
fakebuild = Build(job, None)
fakebuild = Build(job, self.current_build_set, None)
fakebuild.result = 'SKIPPED'
self.addBuild(fakebuild)
def setNodeRequestFailure(self, job):
fakebuild = Build(job, None)
fakebuild = Build(job, self.current_build_set, None)
fakebuild.start_time = time.time()
fakebuild.end_time = time.time()
self.addBuild(fakebuild)
@ -2890,7 +2889,7 @@ class QueueItem(object):
def _setAllJobsSkipped(self):
for job in self.getJobs():
fakebuild = Build(job, None)
fakebuild = Build(job, self.current_build_set, None)
fakebuild.result = 'SKIPPED'
self.addBuild(fakebuild)

View File

@ -1723,7 +1723,7 @@ class Scheduler(threading.Thread):
if final:
# If final is set make sure that the job is not resurrected
# later by re-requesting nodes.
fakebuild = Build(job, None)
fakebuild = Build(job, item.current_build_set, None)
fakebuild.result = 'CANCELED'
buildset.addBuild(fakebuild)
finally: