Fix build leak with paused jobs
In rare occasions we fail to cancel a job because it has not been started on the executor yet. This is normally not a problem other than a slight waste of resources. In this case it just starts, runs to its end end gets collected while discarding the result. However if the job pauses we never resume it so it will never be finished so it can be collected. This can be fixed by canceling the build when we get the paused event before discarding it. Change-Id: I14a3ad24feffcee5e999bef30d7c774e4be4fb92
This commit is contained in:
parent
2029ac77ba
commit
7187a66f5e
|
@ -1183,10 +1183,20 @@ class Scheduler(threading.Thread):
|
|||
log = get_annotated_logger(self.log, build.zuul_event_id)
|
||||
if build.build_set is not build.build_set.item.current_build_set:
|
||||
log.warning("Build %s is not in the current build set", build)
|
||||
try:
|
||||
self.executor.cancel(build)
|
||||
except Exception:
|
||||
log.exception(
|
||||
"Exception while canceling paused build %s", build)
|
||||
return
|
||||
pipeline = build.build_set.item.pipeline
|
||||
if not pipeline:
|
||||
log.warning("Build %s is not associated with a pipeline", build)
|
||||
try:
|
||||
self.executor.cancel(build)
|
||||
except Exception:
|
||||
log.exception(
|
||||
"Exception while canceling paused build %s", build)
|
||||
return
|
||||
pipeline.manager.onBuildPaused(event.build)
|
||||
|
||||
|
|
Loading…
Reference in New Issue