[ARVADOS] updated: a4378cd48648a9ca315713535f651d1bbace322f

git at public.curoverse.com git at public.curoverse.com
Tue Jun 3 16:08:08 EDT 2014


Summary of changes:
 sdk/cli/bin/crunch-job | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

       via  a4378cd48648a9ca315713535f651d1bbace322f (commit)
      from  ab2550bca241736c162a435d62fc3ccb4ac5dc8e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit a4378cd48648a9ca315713535f651d1bbace322f
Author: Brett Smith <brett at curoverse.com>
Date:   Tue Jun 3 16:07:55 2014 -0400

    2953: crunch-job strips permission hints from output manifests.
    
    The API server also strips permission hints from submitted
    collections, and will reject it if the specified UUID doesn't match
    that result.  As a consequence, this is necessary for crunch-job to
    register output with the API server.
    
    Closes #2953.

diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job
index f092558..0befdd5 100755
--- a/sdk/cli/bin/crunch-job
+++ b/sdk/cli/bin/crunch-job
@@ -76,6 +76,7 @@ use strict;
 use POSIX ':sys_wait_h';
 use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
 use Arvados;
+use Digest::MD5 qw(md5_hex);
 use Getopt::Long;
 use IPC::Open2;
 use IO::Select;
@@ -799,21 +800,37 @@ goto ONELEVEL if !defined $main::success;
 
 release_allocation();
 freeze();
+my $collated_output = &collate_output();
+
 if ($job_has_uuid) {
-  $Job->update_attributes('output' => &collate_output(),
-                          'running' => 0,
-                          'success' => $Job->{'output'} && $main::success,
+  $Job->update_attributes('running' => 0,
+                          'success' => $collated_output && $main::success,
                           'finished_at' => scalar gmtime)
 }
 
-if ($Job->{'output'})
+if ($collated_output)
 {
   eval {
-    my $manifest_text = `arv keep get ''\Q$Job->{'output'}\E`;
-    $arv->{'collections'}->{'create'}->execute('collection' => {
-      'uuid' => $Job->{'output'},
+    open(my $orig_manifest, '-|', 'arv', 'keep', 'get', $collated_output)
+        or die "failed to get collated manifest: $!";
+    # Read the original manifest, and strip permission hints from it,
+    # so we can put the result in a Collection.
+    my @manifest_lines = ();
+    while (my $manifest_line = <$orig_manifest>) {
+      my @words = split(/ /, $manifest_line, -1);
+      foreach my $ii (0..$#words) {
+        if ($words[$ii] =~ /^[0-9a-f]{32}\+/) {
+          $words[$ii] =~ s/\+A[0-9a-f]{40}@[0-9a-f]{8}\b//;
+        }
+      }
+      push(@manifest_lines, join(" ", @words));
+    }
+    my $manifest_text = join("", @manifest_lines);
+    my $output = $arv->{'collections'}->{'create'}->execute('collection' => {
+      'uuid' => md5_hex($manifest_text),
       'manifest_text' => $manifest_text,
     });
+    $Job->update_attributes('output' => $output->{uuid});
     if ($Job->{'output_is_persistent'}) {
       $arv->{'links'}->{'create'}->execute('link' => {
         'tail_kind' => 'arvados#user',

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list