X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7c667d8963c7a3cf9acd04c1d938b5273b761228..f782a2505422ad9c853c4c416640c41f3b1e7e79:/services/api/app/models/collection.rb diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb index f212e3358a..9b081dbd2e 100644 --- a/services/api/app/models/collection.rb +++ b/services/api/app/models/collection.rb @@ -2,6 +2,7 @@ require 'arvados/keep' require 'sweep_trashed_collections' class Collection < ArvadosModel + extend CurrentApiClient extend DbCurrentTime include HasUuid include KindAndEtag @@ -372,6 +373,23 @@ 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 + 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 super - ["manifest_text"] end