Remove noop builds from builds list

Those are not submitted to zookeeper but still need to be removed from
the builds list to prevent a memory leak.

Change-Id: I60d2e5e957aa4b7d877dd5e8ba78977eb3e7d7e6
This commit is contained in:
Tobias Henkel
2021-08-17 09:48:17 +02:00
parent 43ff223745
commit a746cc75c1
2 changed files with 6 additions and 12 deletions

View File

@@ -5151,15 +5151,6 @@ class ZuulTestCase(BaseTestCase):
for build in builds:
seen_builds.add(build.uuid)
# Noop jobs are now added to the local build list in the
# executor client, so they can be looked up in the scheduler
# when the build result events are processed.
# As most of the following tests don't make much sense for
# those builds and they are - per definition - completed
# immediately, we can simply skip them.
if build.job.name == "noop":
continue
if not build.build_request_ref:
self.log.debug("%s has not been submitted", build)
return False

View File

@@ -14,6 +14,7 @@
import logging
import time
from contextlib import suppress
from uuid import uuid4
import zuul.executor.common
@@ -214,16 +215,18 @@ class ExecutorClient(object):
log = get_annotated_logger(self.log, build.zuul_event_id)
log.debug("Removing build %s", build.uuid)
with suppress(KeyError):
del self.builds[build.uuid]
if not build.build_request_ref:
log.debug("Build has not been submitted to ZooKeeper")
log.debug("Build %s has not been submitted to ZooKeeper",
build.uuid)
return
build_request = self.executor_api.get(build.build_request_ref)
if build_request:
self.executor_api.remove(build_request)
del self.builds[build.uuid]
def cleanupLostBuildRequests(self):
for build_request in self.executor_api.lostRequests():
try: