Fix exception on retry in source base class

ERROR zuul.Scheduler: Exception processing pipeline check in tenant foobar
Traceback (most recent call last):
  File "/opt/zuul/lib/python3.10/site-packages/zuul/scheduler.py", line 2149, in process_pipelines
    refreshed = self._process_pipeline(
  File "/opt/zuul/lib/python3.10/site-packages/zuul/scheduler.py", line 2241, in _process_pipeline
    self.process_pipeline_trigger_queue(tenant, pipeline)
  File "/opt/zuul/lib/python3.10/site-packages/zuul/scheduler.py", line 2447, in process_pipeline_trigger_queue
    self._process_trigger_event(tenant, pipeline, event)
  File "/opt/zuul/lib/python3.10/site-packages/zuul/scheduler.py", line 2480, in _process_trigger_event
    pipeline.manager.addChange(change, event)
  File "/opt/zuul/lib/python3.10/site-packages/zuul/manager/__init__.py", line 534, in addChange
    self.updateCommitDependencies(change, None, event)
  File "/opt/zuul/lib/python3.10/site-packages/zuul/manager/__init__.py", line 864, in updateCommitDependencies
    dep = source.getChangeByURLWithRetry(match, event)
  File "/opt/zuul/lib/python3.10/site-packages/zuul/source/__init__.py", line 112, in getChangeByURLWithRetry
    return dep
UnboundLocalError: local variable 'dep' referenced before assignment

Change-Id: I1c706e5e5d2d337ec84b8fc1ad5e900191f2362c
This commit is contained in:
Simon Westphahl 2023-02-14 11:26:20 +01:00
parent 776bbc6a6e
commit 8d443f1ada
No known key found for this signature in database
1 changed files with 1 additions and 2 deletions

View File

@ -97,7 +97,7 @@ class BaseSource(object, metaclass=abc.ABCMeta):
# info on subsequent requests we can continue to do the
# requested job work.
try:
dep = self.getChangeByURL(url, event)
return self.getChangeByURL(url, event)
except Exception:
# Note that if the change isn't found dep is None.
# We do not raise in that case and do not need to handle it
@ -109,7 +109,6 @@ class BaseSource(object, metaclass=abc.ABCMeta):
time.sleep(1)
else:
raise
return dep
@abc.abstractmethod
def getChangesDependingOn(self, change, projects, tenant):