5448: Don't create new tasks if $main::success is defined. Add failure count
authorPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 16 Mar 2015 13:40:32 +0000 (09:40 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 16 Mar 2015 13:40:32 +0000 (09:40 -0400)
to cidfile and delete cidfile in reapchildren() to fix Docker cidfile collision.

sdk/cli/bin/crunch-job

index 9fb14b10d3c20e0f6e35e8c4903d2d69d55f4cc0..b3ce782e68854845241a149785bad54e13073f44 100755 (executable)
@@ -721,9 +721,9 @@ for (my $todo_ptr = 0; $todo_ptr <= $#jobstep_todo; $todo_ptr ++)
     $command .= "&& exec arv-mount --by-id --allow-other $ENV{TASK_KEEPMOUNT} --exec ";
     if ($docker_hash)
     {
-      my $cidfile = "$ENV{CRUNCH_TMP}/$ENV{TASK_UUID}.cid";
-      $command .= "crunchstat -cgroup-root=/sys/fs/cgroup -cgroup-parent=docker -cgroup-cid=$cidfile -poll=10000 ";
-      $command .= "$docker_bin run --rm=true --attach=stdout --attach=stderr --attach=stdin -i --user=crunch --cidfile=$cidfile --sig-proxy ";
+      $Jobstep->{cidfile} = "$ENV{CRUNCH_TMP}/$ENV{TASK_UUID}-$Jobstep->{failures}.cid";
+      $command .= "crunchstat -cgroup-root=/sys/fs/cgroup -cgroup-parent=docker -cgroup-cid=$Jobstep->{cidfile} -poll=10000 ";
+      $command .= "$docker_bin run --rm=true --attach=stdout --attach=stderr --attach=stdin -i --user=crunch --cidfile=$Jobstep->{cidfile} --sig-proxy ";
 
       # Dynamically configure the container to use the host system as its
       # DNS server.  Get the host's global addresses from the ip command,
@@ -831,7 +831,7 @@ for (my $todo_ptr = 0; $todo_ptr <= $#jobstep_todo; $todo_ptr ++)
         ||
         (@slot > @freeslot && $todo_ptr+1 > $#jobstep_todo))
   {
-    last THISROUND if $main::please_freeze;
+    last THISROUND if $main::please_freeze || defined($main::success);
     if ($main::please_info)
     {
       $main::please_info = 0;
@@ -1065,6 +1065,11 @@ sub reapchildren
   push @freeslot, $proc{$pid}->{slot};
   delete $proc{$pid};
 
+  if (defined($Jobstep->{cidfile})) {
+    unlink $Jobstep->{cidfile};
+    delete $Jobstep->{cidfile};
+  }
+
   if ($task_success) {
     # Load new tasks
     my $newtask_list = [];