Merge branch 'master' into 3586-job-priority
[arvados.git] / sdk / cli / bin / crunch-job
index 4d2aad997a3e31dd8ff26b93ffd336c5b092c4e0..0d31afcb874a5c02b965827aa88636f7b29463ea 100755 (executable)
@@ -685,13 +685,13 @@ for (my $todo_ptr = 0; $todo_ptr <= $#jobstep_todo; $todo_ptr ++)
       $command .= "--env=\QCRUNCH_SRC=/tmp/crunch-src\E ";
       $command .= "\Q$docker_hash\E ";
       $command .= "stdbuf --output=0 --error=0 ";
-      $command .= "perl - ";
+      $command .= "perl - " if ($build_script);
       $command .= "/tmp/crunch-src/crunch_scripts/" . $Job->{"script"};
     } else {
       # Non-docker run
       $command .= "crunchstat -cgroup-root=/sys/fs/cgroup -poll=10000 ";
       $command .= "stdbuf --output=0 --error=0 ";
-      $command .= "perl - ";
+      $command .= "perl - " if ($build_script);
       $command .= "$ENV{CRUNCH_SRC}/crunch_scripts/" . $Job->{"script"};
     }
 
@@ -860,7 +860,8 @@ else {
     my $output = $arv->{'collections'}->{'create'}->execute('collection' => {
       'manifest_text' => $orig_manifest_text,
     });
-    Log(undef, "output " . $output->{portable_data_hash});
+    Log(undef, "output uuid " . $output->{uuid});
+    Log(undef, "output hash " . $output->{portable_data_hash});
     $Job->update_attributes('output' => $output->{portable_data_hash}) if $job_has_uuid;
   };
   if ($@) {
@@ -1335,7 +1336,7 @@ sub save_meta
   return if $justcheckpoint;  # checkpointing is not relevant post-Warehouse.pm
 
   $local_logfile->flush;
-  my $cmd = "arv-put --filename ''\Q$keep_logfile\E "
+  my $cmd = "arv-put --portable-data-hash --filename ''\Q$keep_logfile\E "
       . quotemeta($local_logfile->filename);
   my $loglocator = `$cmd`;
   die "system $cmd failed: $?" if $?;
@@ -1493,8 +1494,12 @@ for my $dir ($destdir, $task_work) {
 open L, ">", "$destdir.lock" or die "$destdir.lock: $!";
 flock L, LOCK_EX;
 if (readlink ("$destdir.commit") eq $commit && -d $destdir) {
-    exec(@ARGV) if @ARGV;
-    exit 0;
+    if (@ARGV) {
+        exec(@ARGV);
+        die "Cannot exec `@ARGV`: $!";
+    } else {
+        exit 0;
+    }
 }
 
 unlink "$destdir.commit";
@@ -1542,6 +1547,7 @@ close L;
 
 if (@ARGV) {
     exec(@ARGV);
+    die "Cannot exec `@ARGV`: $!";
 } else {
     exit 0;
 }