From a746cc75c1a30e4039066b69465411ba0b9b2c19 Mon Sep 17 00:00:00 2001 From: Tobias Henkel Date: Tue, 17 Aug 2021 09:48:17 +0200 Subject: [PATCH] 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 --- tests/base.py | 9 --------- zuul/executor/client.py | 9 ++++++--- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/base.py b/tests/base.py index 4f921eb0bf..202500cd60 100644 --- a/tests/base.py +++ b/tests/base.py @@ -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 diff --git a/zuul/executor/client.py b/zuul/executor/client.py index 36e6967fd6..3a67a64938 100644 --- a/zuul/executor/client.py +++ b/zuul/executor/client.py @@ -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: