executor: prevent restart exception on bad build log

This change prevents PermissionDenied exception from blocking
executor service restart when a job build contains a directory
with non writable mode bit.

Change-Id: I53aaf77ffafcb3d94350b6ce25dff124ecfe1a78
This commit is contained in:
Tristan Cacqueray 2020-01-13 14:31:41 +00:00
parent f2becc9184
commit 98238ede64
1 changed files with 5 additions and 1 deletions

View File

@ -2409,7 +2409,11 @@ class ExecutorServer(object):
if not os.path.isdir(fn):
continue
self.log.info("Deleting stale jobdir %s", fn)
shutil.rmtree(os.path.join(self.jobdir_root, fn))
# We use rm here instead of shutil because of
# https://bugs.python.org/issue22040
jobdir = os.path.join(self.jobdir_root, fn)
if subprocess.Popen(["rm", "-Rf", jobdir]).wait():
raise RuntimeError("Couldn't delete: " + jobdir)
self.job_workers = {}
self.disk_accountant = DiskAccountant(self.jobdir_root,