Merge "Delete stale jobdirs at startup"

This commit is contained in:
Zuul 2018-07-18 20:57:34 +00:00 committed by Gerrit Code Review
commit c8176ceba0
2 changed files with 10 additions and 1 deletions

View File

@ -86,7 +86,7 @@ class Executor(zuul.cmd.ZuulDaemonApp):
job_dir=self.job_dir))
sys.exit(1)
else:
self.job_dir = tempfile.gettempdir()
self.job_dir = tempfile.mkdtemp()
self.setup_logging('executor', 'log_config')
self.log = logging.getLogger("zuul.Executor")

View File

@ -1897,6 +1897,15 @@ class ExecutorServer(object):
with open(os.path.join(zuul_dir, '__init__.py'), 'w'):
pass
# If keep is not set, ensure the job dir is empty on startup,
# in case we were uncleanly shut down.
if not self.keep_jobdir:
for fn in os.listdir(self.jobdir_root):
if not os.path.isdir(fn):
continue
self.log.info("Deleting stale jobdir %s", fn)
shutil.rmtree(os.path.join(self.jobdir_root, fn))
self.job_workers = {}
self.disk_accountant = DiskAccountant(self.jobdir_root,
self.disk_limit_per_job,