X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/42bf31f017a009585eaac2fe44a83b2596b3e5c8..7f88afd565b76903ad4b27fb896ff0cd844dfb7f:/services/api/app/models/container.rb diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb index 8feee77ff2..2443da4551 100644 --- a/services/api/app/models/container.rb +++ b/services/api/app/models/container.rb @@ -21,7 +21,8 @@ class Container < ArvadosModel # already know how to properly treat them. attribute :secret_mounts, :jsonbHash, default: {} attribute :runtime_status, :jsonbHash, default: {} - attribute :runtime_auth_scopes, :jsonbHash, default: {} + attribute :runtime_auth_scopes, :jsonbArray, default: [] + attribute :output_storage_classes, :jsonbArray, default: lambda { Rails.configuration.DefaultStorageClasses } serialize :environment, Hash serialize :mounts, Hash @@ -79,6 +80,7 @@ class Container < ArvadosModel t.add :lock_count t.add :gateway_address t.add :interactive_session_started + t.add :output_storage_classes end # Supported states for a container @@ -104,11 +106,11 @@ class Container < ArvadosModel end def self.full_text_searchable_columns - super - ["secret_mounts", "secret_mounts_md5", "runtime_token", "gateway_address"] + super - ["secret_mounts", "secret_mounts_md5", "runtime_token", "gateway_address", "output_storage_classes"] end def self.searchable_columns *args - super - ["secret_mounts_md5", "runtime_token", "gateway_address"] + super - ["secret_mounts_md5", "runtime_token", "gateway_address", "output_storage_classes"] end def logged_attributes @@ -187,7 +189,8 @@ class Container < ArvadosModel secret_mounts: req.secret_mounts, runtime_token: req.runtime_token, runtime_user_uuid: runtime_user.uuid, - runtime_auth_scopes: runtime_auth_scopes + runtime_auth_scopes: runtime_auth_scopes, + output_storage_classes: req.output_storage_classes, } end act_as_system_user do @@ -286,7 +289,22 @@ class Container < ArvadosModel candidates = candidates.where('secret_mounts_md5 = ?', secret_mounts_md5) log_reuse_info(candidates) { "after filtering on secret_mounts_md5 #{secret_mounts_md5.inspect}" } - candidates = candidates.where_serialized(:runtime_constraints, resolve_runtime_constraints(attrs[:runtime_constraints]), md5: true) + if attrs[:runtime_constraints]['cuda'].nil? + attrs[:runtime_constraints]['cuda'] = { + 'device_count' => 0, + 'driver_version' => '', + 'hardware_capability' => '', + } + end + + candidates_inc_cuda = candidates.where_serialized(:runtime_constraints, resolve_runtime_constraints(attrs[:runtime_constraints]), md5: true) + if candidates_inc_cuda.count == 0 and attrs[:runtime_constraints]['cuda']['device_count'] == 0 + # Fallback search on containers introduced before CUDA support, + # exclude empty CUDA request from query + candidates = candidates.where_serialized(:runtime_constraints, resolve_runtime_constraints(attrs[:runtime_constraints].except('cuda')), md5: true) + else + candidates = candidates_inc_cuda + end log_reuse_info(candidates) { "after filtering on runtime_constraints #{attrs[:runtime_constraints].inspect}" } log_reuse_info { "checking for state=Complete with readable output and log..." } @@ -467,7 +485,8 @@ class Container < ArvadosModel :environment, :mounts, :output_path, :priority, :runtime_constraints, :scheduling_parameters, :secret_mounts, :runtime_token, - :runtime_user_uuid, :runtime_auth_scopes) + :runtime_user_uuid, :runtime_auth_scopes, + :output_storage_classes) end case self.state @@ -605,7 +624,8 @@ class Container < ArvadosModel self.runtime_auth_scopes = ["all"] end - # generate a new token + # Generate a new token. This runs with admin credentials as it's done by a + # dispatcher user, so expires_at isn't enforced by API.MaxTokenLifetime. self.auth = ApiClientAuthorization. create!(user_id: User.find_by_uuid(self.runtime_user_uuid).id, api_client_id: 0,