Do not mount $TASK_WORK inside the container; scratch space is entirely
authorPeter Amstutz <peter.amstutz@curoverse.com>
Wed, 2 Jul 2014 18:12:50 +0000 (14:12 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Wed, 2 Jul 2014 18:12:50 +0000 (14:12 -0400)
contained so it can be cleaned up by docker when the container is deleted.  Add
--rm=true to automatically clean up docker containers when they exit.

sdk/cli/bin/crunch-job

index f758493adf14fef917c5622a15fd46cec8ae0e84..9e580d3d19b9f2e35f43f17154dc5d112f6c4785 100755 (executable)
@@ -640,7 +640,6 @@ for (my $todo_ptr = 0; $todo_ptr <= $#jobstep_todo; $todo_ptr ++)
     my $command =
        "if [ -e $ENV{TASK_WORK} ]; then rm -rf $ENV{TASK_WORK}; fi; "
         ."mkdir -p $ENV{JOB_WORK} $ENV{CRUNCH_TMP} $ENV{TASK_WORK} $ENV{TASK_KEEPMOUNT} $ENV{HOME}"
-        ."&& chmod og+wrx $ENV{TASK_WORK}"
        ."&& cd $ENV{CRUNCH_TMP} ";
     if ($build_script)
     {
@@ -652,14 +651,13 @@ for (my $todo_ptr = 0; $todo_ptr <= $#jobstep_todo; $todo_ptr ++)
     if ($docker_hash)
     {
       $command .= "crunchstat -cgroup-root=/sys/fs/cgroup -cgroup-parent=docker -cgroup-cid=$ENV{TASK_WORK}/docker.cid -poll=10000 ";
-      $command .= "$docker_bin run --attach=stdout --attach=stderr --user=crunch --cidfile=$ENV{TASK_WORK}/docker.cid ";
+      $command .= "$docker_bin run --rm=true --attach=stdout --attach=stderr --user=crunch --cidfile=$ENV{TASK_WORK}/docker.cid ";
       # Dynamically configure the container to use the host system as its
       # DNS server.  Get the host's global addresses from the ip command,
       # and turn them into docker --dns options using gawk.
       $command .=
           q{$(ip -o address show scope global |
               gawk 'match($4, /^([0-9\.:]+)\//, x){print "--dns", x[1]}') };
-      $command .= "--volume=\Q$ENV{TASK_WORK}:/tmp/crunch-job:rw\E ";
       $command .= "--volume=\Q$ENV{CRUNCH_SRC}:/tmp/crunch-src:ro\E ";
       $command .= "--volume=\Q$ENV{TASK_KEEPMOUNT}:/keep:ro\E ";
       $command .= "--env=\QHOME=/home/crunch\E ";