[ARVADOS] updated: 338632b2de45ad487f9ba24a98b6e06d90893f8c

git at public.curoverse.com git at public.curoverse.com
Fri Aug 8 13:42:35 EDT 2014


Summary of changes:
 sdk/cli/bin/crunch-job                | 18 ++++++++++--------
 services/api/app/models/collection.rb |  8 +++-----
 2 files changed, 13 insertions(+), 13 deletions(-)

       via  338632b2de45ad487f9ba24a98b6e06d90893f8c (commit)
      from  5acaab6b30d0a08653418dfea9702754197b0738 (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 338632b2de45ad487f9ba24a98b6e06d90893f8c
Author: Brett Smith <brett at curoverse.com>
Date:   Fri Aug 8 13:44:00 2014 -0400

    3527: Support using a Docker image from any stream in a Collection.
    
    This makes Docker image detection more consistent between crunch-job
    and the API server, and is more user-friendly.

diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job
index ad43303..06b3da9 100755
--- a/sdk/cli/bin/crunch-job
+++ b/sdk/cli/bin/crunch-job
@@ -499,16 +499,17 @@ if (!$have_slurm)
 
 # If this job requires a Docker image, install that.
 my $docker_bin = "/usr/bin/docker.io";
-my ($docker_locator, $docker_hash);
+my ($docker_locator, $docker_stream, $docker_hash);
 if ($docker_locator = $Job->{docker_image_locator}) {
-  $docker_hash = find_docker_hash($docker_locator);
+  ($docker_stream, $docker_hash) = find_docker_image($docker_locator);
   if (!$docker_hash)
   {
     croak("No Docker image hash found from locator $docker_locator");
   }
+  $docker_stream =~ s/^\.//;
   my $docker_install_script = qq{
 if ! $docker_bin images -q --no-trunc | grep -qxF \Q$docker_hash\E; then
-    arv-get \Q$docker_locator/$docker_hash.tar\E | $docker_bin load
+    arv-get \Q$docker_locator$docker_stream/$docker_hash.tar\E | $docker_bin load
 fi
 };
   my $docker_pid = fork();
@@ -1466,18 +1467,19 @@ sub must_lock_now
   }
 }
 
-sub find_docker_hash {
-  # Given a Keep locator, return the hash of the image inside it.
+sub find_docker_image {
+  # Given a Keep locator, check to see if it contains a Docker image.
+  # If so, return its stream name and Docker hash.
+  # If not, return undef for both values.
   my $locator = shift;
-  my $docker_hash;
   if (my $image = $arv->{collections}->{get}->execute(uuid => $locator)) {
     my @file_list = @{$image->{files}};
     if ((scalar(@file_list) == 1) &&
         ($file_list[0][1] =~ /^([0-9A-Fa-f]{64})\.tar$/)) {
-      $docker_hash = $1;
+      return ($file_list[0][0], $1);
     }
   }
-  return $docker_hash;
+  return (undef, undef);
 }
 
 __DATA__
diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 2601a27..50dd42c 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -164,11 +164,9 @@ class Collection < ArvadosModel
     if loc = Locator.parse(search_term)
       loc.strip_hints!
       coll_match = readable_by(*readers).where(uuid: loc.to_s).first
-      if coll_match.andand.files.andand.size == 1
-        dirname, basename = coll_match.files.first[0, 2]
-        if (dirname == ".") and (basename =~ /^[0-9A-Fa-f]{64}\.tar$/)
-          return [loc.to_s]
-        end
+      if coll_match and (coll_match.files.size == 1) and
+          (coll_match.files[0][1] =~ /^[0-9A-Fa-f]{64}\.tar$/)
+        return [loc.to_s]
       end
     end
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list