From 45d9f251b1082b995377046e8e7b40ccd105f645 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 6 Aug 2024 07:19:31 -0700 Subject: [PATCH] Handle exceptions when forcibly canceling builds When builds are forcibly canceled due to pipeline deletions, there are some race conditions that can result in exceptions in the executor. Handle these conditions explicitly to avoid unecessary tracebacks in the logs. Change-Id: I2c85cbcd8b50b746b338418d8fa93ea5c7c58876 --- zuul/executor/server.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/zuul/executor/server.py b/zuul/executor/server.py index a3c01f66bf..9afaf3ea57 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -4024,7 +4024,11 @@ class ExecutorServer(BaseMergeServer): # to aid the test suite in avoiding races. if build_event == JobRequestEvent.CANCELED: self.stopJob(build_request) - self.executor_api.fulfillCancel(build_request) + try: + self.executor_api.fulfillCancel(build_request) + except NoNodeError: + self.log.warning("Unable to fulfill cancel request, " + "build request may have been removed") elif build_event == JobRequestEvent.RESUMED: self.resumeJob(build_request) self.executor_api.fulfillResume(build_request) @@ -4460,8 +4464,11 @@ class ExecutorServer(BaseMergeServer): # should still update the build request just in case, in # order to prevent another executor from starting an # unecessary build. - self._retry(build_request.lock, self.executor_api.update, - build_request) + try: + self._retry(build_request.lock, self.executor_api.update, + build_request) + except JobRequestNotFound as e: + self.log.warning("Build was removed: %s", str(e)) self._retry(build_request.lock, self.executor_api.unlock, build_request)