Fix not found being raised when iterating
Instead of re-raising a not found exception just silence those exceptions when iterating (and do not yield that job back in the first place) and then remove the job from the jobboard internals to avoid further iteration. Fixes bug 1304562 Change-Id: Ibc6d3ea55dc19e70104bfc801283b8ad919496c4
This commit is contained in:
@@ -192,8 +192,8 @@ class ZookeeperJobBoard(jobboard.JobBoard):
|
||||
if only_unclaimed:
|
||||
ok_states = UNCLAIMED_JOB_STATES
|
||||
with self._job_mutate:
|
||||
known_jobs = list(six.itervalues(self._known_jobs))
|
||||
for (job, posting_state) in known_jobs:
|
||||
known_jobs = list(six.iteritems(self._known_jobs))
|
||||
for (path, (job, posting_state)) in known_jobs:
|
||||
if posting_state != _READY:
|
||||
continue
|
||||
try:
|
||||
@@ -202,6 +202,10 @@ class ZookeeperJobBoard(jobboard.JobBoard):
|
||||
except excp.JobFailure as e:
|
||||
LOG.warn("Failed determining the state of job %s"
|
||||
" due to: %s", job.uuid, e)
|
||||
except excp.NotFound:
|
||||
# Someone destroyed it while we are iterating.
|
||||
with self._job_mutate:
|
||||
self._remove_job(path)
|
||||
|
||||
def _remove_job(self, path):
|
||||
LOG.debug("Removing job that was at path: %s", path)
|
||||
|
||||
Reference in New Issue
Block a user