Merge branch 'master' into 3193-manage-account
[arvados.git] / sdk / cli / bin / crunch-job
index ca2e8c49a5b66048c0918f8725a95c50f2365a86..462b78c5f8a8f056e0acd21a4bc25c1651ae0fda 100755 (executable)
@@ -82,6 +82,7 @@ use IPC::Open2;
 use IO::Select;
 use File::Temp;
 use Fcntl ':flock';
+use File::Path qw( make_path );
 
 $ENV{"TMPDIR"} ||= "/tmp";
 unless (defined $ENV{"CRUNCH_TMP"}) {
@@ -91,6 +92,12 @@ unless (defined $ENV{"CRUNCH_TMP"}) {
     $ENV{"CRUNCH_TMP"} .= "-$<";
   }
 }
+
+# Create the tmp directory if it does not exist
+if ( ! -d $ENV{"CRUNCH_TMP"} ) {
+  make_path $ENV{"CRUNCH_TMP"} or die "Failed to create temporary working directory: " . $ENV{"CRUNCH_TMP"};
+}
+
 $ENV{"JOB_WORK"} = $ENV{"CRUNCH_TMP"} . "/work";
 $ENV{"CRUNCH_INSTALL"} = "$ENV{CRUNCH_TMP}/opt";
 $ENV{"CRUNCH_WORK"} = $ENV{"JOB_WORK"}; # deprecated
@@ -985,27 +992,29 @@ sub reapchildren
   push @freeslot, $proc{$pid}->{slot};
   delete $proc{$pid};
 
-  # Load new tasks
-  my $newtask_list = [];
-  my $newtask_results;
-  do {
-    $newtask_results = $arv->{'job_tasks'}->{'list'}->execute(
-      'where' => {
-        'created_by_job_task_uuid' => $Jobstep->{'arvados_task'}->{uuid}
-      },
-      'order' => 'qsequence',
-      'offset' => scalar(@$newtask_list),
-    );
-    push(@$newtask_list, @{$newtask_results->{items}});
-  } while (@{$newtask_results->{items}});
-  foreach my $arvados_task (@$newtask_list) {
-    my $jobstep = {
-      'level' => $arvados_task->{'sequence'},
-      'failures' => 0,
-      'arvados_task' => $arvados_task
-    };
-    push @jobstep, $jobstep;
-    push @jobstep_todo, $#jobstep;
+  if ($task_success) {
+    # Load new tasks
+    my $newtask_list = [];
+    my $newtask_results;
+    do {
+      $newtask_results = $arv->{'job_tasks'}->{'list'}->execute(
+        'where' => {
+          'created_by_job_task_uuid' => $Jobstep->{'arvados_task'}->{uuid}
+        },
+        'order' => 'qsequence',
+        'offset' => scalar(@$newtask_list),
+      );
+      push(@$newtask_list, @{$newtask_results->{items}});
+    } while (@{$newtask_results->{items}});
+    foreach my $arvados_task (@$newtask_list) {
+      my $jobstep = {
+        'level' => $arvados_task->{'sequence'},
+        'failures' => 0,
+        'arvados_task' => $arvados_task
+      };
+      push @jobstep, $jobstep;
+      push @jobstep_todo, $#jobstep;
+    }
   }
 
   $progress_is_dirty = 1;