X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/043dd5e0f26626509d522a48f27e6f3fbfb023ef..bad73626c4208fb95ac8e3d9503fc4482f936cb3:/services/api/app/models/container.rb?ds=sidebyside diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb index 5833c2251f..a880b65ac5 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: Rails.configuration.DefaultStorageClasses serialize :environment, Hash serialize :mounts, Hash @@ -29,6 +30,7 @@ class Container < ArvadosModel serialize :command, Array serialize :scheduling_parameters, Hash + after_find :fill_container_defaults_after_find before_validation :fill_field_defaults, :if => :new_record? before_validation :set_timestamps before_validation :check_lock @@ -76,6 +78,9 @@ class Container < ArvadosModel t.add :runtime_user_uuid t.add :runtime_auth_scopes t.add :lock_count + t.add :gateway_address + t.add :interactive_session_started + t.add :output_storage_classes end # Supported states for a container @@ -101,11 +106,11 @@ class Container < ArvadosModel end def self.full_text_searchable_columns - super - ["secret_mounts", "secret_mounts_md5", "runtime_token"] + 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"] + super - ["secret_mounts_md5", "runtime_token", "gateway_address", "output_storage_classes"] end def logged_attributes @@ -184,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 @@ -207,17 +213,16 @@ class Container < ArvadosModel # containers are suitable). def self.resolve_runtime_constraints(runtime_constraints) rc = {} - defaults = { - 'keep_cache_ram' => - Rails.configuration.Containers.DefaultKeepCacheRAM, - } - defaults.merge(runtime_constraints).each do |k, v| + runtime_constraints.each do |k, v| if v.is_a? Array rc[k] = v[0] else rc[k] = v end end + if rc['keep_cache_ram'] == 0 + rc['keep_cache_ram'] = Rails.configuration.Containers.DefaultKeepCacheRAM + end rc end @@ -465,7 +470,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 @@ -478,7 +484,10 @@ class Container < ArvadosModel when Running permitted.push :priority, *progress_attrs if self.state_changed? - permitted.push :started_at + permitted.push :started_at, :gateway_address + end + if !self.interactive_session_started_was + permitted.push :interactive_session_started end when Complete @@ -600,7 +609,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,