diff --git a/zuul/cmd/executor.py b/zuul/cmd/executor.py index 5e5ea377d2..ba7426315d 100755 --- a/zuul/cmd/executor.py +++ b/zuul/cmd/executor.py @@ -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") diff --git a/zuul/executor/server.py b/zuul/executor/server.py index 237a70f41c..cac864803e 100644 --- a/zuul/executor/server.py +++ b/zuul/executor/server.py @@ -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,