madecoste / swarming

Automatically exported from code.google.com/p/swarming
Apache License 2.0
0 stars 1 forks source link

Create private temporary directory in task_runner.py #157

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Use case:
Temporary files accumulate with broken tests. 

AI:
Create a temporary TEMP dir and override the environment variables so it's used 
by the task executed. After the task completes, the directory is deleted.

Goal:
It simplifies a lot of the cleanup work being done in 
client/tools/swarm_cleanup.py and reduces the risk of accumulation of files not 
cleaned up already by this script.

Original issue reported on code.google.com by maruel@chromium.org on 18 Sep 2014 at 7:05

GoogleCodeExporter commented 9 years ago
We should also consider dropping a .task/.pid/.args file(s) in there so that 
another process (possibly after a machine reboot) can identify that all of 
these private temp dirs are no longer in use and can be safely deleted.

It may also be worth using PendMoves on windows machines to pend-delete the 
.pid files from these directories. Then we can identify the directories by name 
and nuke the ones without a .pid file. This allows us to not worry about 'kill 
0' functionality on windows.

In the normal (non-reboot) case, the task runner would just delete the .pid 
file.

Probably something like:
  for dir in TEMP/*.swarming_task:
    if !exists(dir/.pid) || kill(0, read(dir/.pid)):
      rm -rf dir

  $dir = mkdtemp
  write_pidfile($dir)
  pend_delete_pidfile($dir)
  mv $dir $dir.swarming_task
  env[TEMP] = $dir.swarming_task

Original comment by iannucci@chromium.org on 18 Sep 2014 at 9:23

GoogleCodeExporter commented 9 years ago

Original comment by maruel@chromium.org on 2 Dec 2014 at 7:53