X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/aceb1f665394d84ec238d6654b5447a37c2bc3b3..d6446b03e2f5d5079a870bdd7b963456dc12b485:/services/api/app/models/container.rb diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb index d2e76f74e3..ee338b81ff 100644 --- a/services/api/app/models/container.rb +++ b/services/api/app/models/container.rb @@ -51,8 +51,15 @@ class Container < ArvadosModel after_save :update_cr_logs after_save :handle_completed - has_many :container_requests, :foreign_key => :container_uuid, :class_name => 'ContainerRequest', :primary_key => :uuid - belongs_to :auth, :class_name => 'ApiClientAuthorization', :foreign_key => :auth_uuid, :primary_key => :uuid + has_many :container_requests, + class_name: 'ContainerRequest', + foreign_key: 'container_uuid', + primary_key: 'uuid' + belongs_to :auth, + class_name: 'ApiClientAuthorization', + foreign_key: 'auth_uuid', + primary_key: 'uuid', + optional: true api_accessible :user, extend: :common do |t| t.add :command @@ -312,7 +319,7 @@ class Container < ArvadosModel resolved_runtime_constraints.delete('cuda') ].uniq end - reusable_runtime_constraints = hash_product(runtime_constraint_variations) + reusable_runtime_constraints = hash_product(**runtime_constraint_variations) .map { |v| resolved_runtime_constraints.merge(v) } candidates = candidates.where_serialized(:runtime_constraints, reusable_runtime_constraints, md5: true, multivalue: true) @@ -379,7 +386,7 @@ class Container < ArvadosModel if self.state != Queued raise LockFailedError.new("cannot lock when #{self.state}") end - self.update_attributes!(state: Locked) + self.update!(state: Locked) end end @@ -397,7 +404,7 @@ class Container < ArvadosModel if self.state != Locked raise InvalidStateTransitionError.new("cannot unlock when #{self.state}") end - self.update_attributes!(state: Queued) + self.update!(state: Queued) end end @@ -642,7 +649,7 @@ class Container < ArvadosModel # ensure the token doesn't validate later in the same # transaction (e.g., in a test case) by satisfying expires_at > # transaction timestamp. - self.auth.andand.update_attributes(expires_at: db_transaction_time) + self.auth.andand.update(expires_at: db_transaction_time) self.auth = nil return elsif self.auth @@ -835,7 +842,7 @@ class Container < ArvadosModel # Queued with priority 0. (OTOH, if the child is already # running, leave it alone so it can get cancelled the # usual way, get a copy of the log collection, etc.) - cr.update_attributes!(state: ContainerRequest::Final) + cr.update!(state: ContainerRequest::Final) end end end