Delete repo if unable to reset

If a merger or executor is unable to reset a repo, we currently
simply log the message "Unable to reset repo".  Instead, let's
assume that it is permanently broken and rmtree it so that future
attempts will automatically recover.

Change-Id: I17b051d70a9c5800019bf9ef7e0800558614cadd
This commit is contained in:
James E. Blair 2022-04-13 14:44:51 -07:00
parent d6ace2cec6
commit 1cd1d3f4de
1 changed files with 12 additions and 7 deletions

View File

@ -401,13 +401,18 @@ class Repo(object):
log.debug("Resetting repository %s", self.local_path)
self.createRepoObject(zuul_event_id, build=build)
if process_worker is None:
self._reset(self.local_path, self.env, log)
else:
job = process_worker.submit(Repo._reset, self.local_path, self.env)
messages = job.result()
for message in messages:
log.debug(message)
try:
if process_worker is None:
self._reset(self.local_path, self.env, log)
else:
job = process_worker.submit(
Repo._reset, self.local_path, self.env)
messages = job.result()
for message in messages:
log.debug(message)
except Exception:
shutil.rmtree(self.local_path)
raise
def getBranchHead(self, branch, zuul_event_id=None):
repo = self.createRepoObject(zuul_event_id)