[ARVADOS] created: ebb0138d3f522a3d0c1406c874c77c9a2883b21e

Git user git at public.curoverse.com
Thu Mar 9 10:55:50 EST 2017


        at  ebb0138d3f522a3d0c1406c874c77c9a2883b21e (commit)


commit ebb0138d3f522a3d0c1406c874c77c9a2883b21e
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed Mar 8 17:06:46 2017 -0500

    8567: Fix docker_migration_pdh to seach head/tail_uuid (PDH doesn't work). Select correct image in both directions.

diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 9b081db..1eba251 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -373,21 +373,31 @@ class Collection < ArvadosModel
     find_all_for_docker_image(search_term, search_tag, readers).first
   end
 
-  # If the given pdh is an old-format docker image, old-format images
-  # aren't supported by the compute nodes according to site config,
-  # and a migrated new-format image is available, return the migrated
-  # image's pdh. Otherwise, just return pdh.
-  def self.docker_migration_pdh(read_users, pdh)
-    if Rails.configuration.docker_image_formats.include?('v1')
-      return pdh
+  # If the collection docker image has been migrated from image format v1 to
+  # v2, determine what version to use according to the site config and return
+  # the PDH of the right one. Otherwise, just return PDH.
+  def self.docker_migration_pdh(read_users, coll)
+    if Rails.configuration.docker_image_formats.include?('v2')
+      # Prefer v2 image (link head) from migration links, else assume
+      # collection is a v2 image.
+      Collection.readable_by(*read_users).
+        joins('INNER JOIN links ON links.head_uuid=collections.uuid').
+        where('tail_uuid=? AND link_class=? AND links.owner_uuid=?',
+              coll.uuid, 'docker_image_migration', system_user_uuid).
+        order('links.created_at desc').
+        select('portable_data_hash').
+        first.andand.portable_data_hash || coll.portable_data_hash
+    else
+      # Select v1 image (link tail) from migration links, else assume
+      # collection is a v2 image.
+      Collection.readable_by(*read_users).
+        joins('INNER JOIN links ON links.tail_uuid=collections.uuid').
+        where('head_uuid=? AND link_class=? AND links.owner_uuid=?',
+              coll.uuid, 'docker_image_migration', system_user_uuid).
+        order('links.created_at desc').
+        select('portable_data_hash').
+        first.andand.portable_data_hash || coll.portable_data_hash
     end
-    Collection.readable_by(*read_users).
-      joins('INNER JOIN links ON head_uuid=portable_data_hash').
-      where('tail_uuid=? AND link_class=? AND links.owner_uuid=?',
-            pdh, 'docker_image_migration', system_user_uuid).
-      order('links.created_at desc').
-      select('portable_data_hash').
-      first.andand.portable_data_hash || pdh
   end
 
   def self.searchable_columns operator
diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb
index 6bb8fb0..4d158f0 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -235,7 +235,7 @@ class ContainerRequest < ArvadosModel
     if !coll
       raise ArvadosModel::UnresolvableContainerError.new "docker image #{container_image.inspect} not found"
     end
-    return Collection.docker_migration_pdh([current_user], coll.portable_data_hash)
+    return Collection.docker_migration_pdh([current_user], coll)
   end
 
   def set_container
diff --git a/services/api/app/models/job.rb b/services/api/app/models/job.rb
index 80a03e2..e76bbb8 100644
--- a/services/api/app/models/job.rb
+++ b/services/api/app/models/job.rb
@@ -212,8 +212,7 @@ class Job < ArvadosModel
         if image_tag = attrs[:runtime_constraints]["docker_image_tag"]
           image_search += ":#{image_tag}"
         end
-        image_locator = Collection.
-          for_latest_docker_image(image_search).andand.portable_data_hash
+        image_locator = Collection.for_latest_docker_image(image_search)
       else
         image_locator = nil
       end
@@ -435,7 +434,7 @@ class Job < ArvadosModel
                                :docker_image_locator) do |image_search|
       image_tag = runtime_constraints['docker_image_tag']
       if coll = Collection.for_latest_docker_image(image_search, image_tag)
-        [true, coll.portable_data_hash]
+        [true, coll]
       else
         [false, "not found for #{image_search}"]
       end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list