Ignore job requests not found for lost requests

Avoid exeptions during merge/executor job cleanup by ignoring
JobRequestNotFound errors. NoNodeErrors were already ignored.

ERROR apscheduler.executors.default: Job "Scheduler._runMergeRequestCleanup ..." raised an exception
Traceback (most recent call last):
  File "/opt/zuul/lib/python3.11/site-packages/zuul/zk/job_request_queue.py", line 372, in refresh
    data, zstat = self.kazoo_client.get(request.path)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/zuul/lib/python3.11/site-packages/kazoo/client.py", line 1165, in get
    return self.get_async(path, watch=watch).get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/zuul/lib/python3.11/site-packages/kazoo/handlers/utils.py", line 86, in get
    raise self._exception
kazoo.exceptions.NoNodeError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/opt/zuul/lib/python3.11/site-packages/apscheduler/executors/base.py", line 125, in run_job
    retval = job.func(*job.args, **job.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/zuul/lib/python3.11/site-packages/zuul/scheduler.py", line 881, in _runMergeRequestCleanup
    self.merger.cleanupLostMergeRequests()
  File "/opt/zuul/lib/python3.11/site-packages/zuul/merger/client.py", line 190, in cleanupLostMergeRequests
    for merge_request in self.merger_api.lostRequests():
  File "/opt/zuul/lib/python3.11/site-packages/zuul/zk/job_request_queue.py", line 521, in lostRequests
    self.refresh(req)
  File "/opt/zuul/lib/python3.11/site-packages/zuul/zk/job_request_queue.py", line 374, in refresh
    raise JobRequestNotFound(
zuul.zk.exceptions.JobRequestNotFound: Could not refresh <MergeRequest 56a4c4a611f4421c833249b00152f32f, ...

Change-Id: Ie9f70e325df949652c0633ecfc5d34226d51cea0
This commit is contained in:
Simon Westphahl
2025-03-26 15:17:17 +01:00
parent b2570d1df5
commit b65bde9162

View File

@@ -521,7 +521,7 @@ class JobRequestQueue:
self.refresh(req)
if req.state not in states:
continue
except NoNodeError:
except (NoNodeError, JobRequestNotFound):
# Request was removed in the meantime
continue
yield req