X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/df50f6c77c345507502eae91bcb4713b5f8bcd5b..fd6df03fd625fe0f9126205ab324df8533fdcc79:/services/api/app/models/container.rb diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb index e8a70499a9..079ac4c299 100644 --- a/services/api/app/models/container.rb +++ b/services/api/app/models/container.rb @@ -39,6 +39,7 @@ class Container < ArvadosModel before_save :update_secret_mounts_md5 before_save :scrub_secret_mounts before_save :clear_runtime_status_when_queued + after_save :update_cr_logs after_save :handle_completed after_save :propagate_priority after_commit { UpdatePriority.run_update_thread } @@ -451,7 +452,7 @@ class Container < ArvadosModel if current_api_client_authorization.andand.uuid.andand == self.auth_uuid # The contained process itself can update progress indicators, # but can't change priority etc. - permitted = permitted & [:state, :progress, :output] + permitted = permitted & (progress_attrs + final_attrs + [:state] - [:log]) elsif self.locked_by_uuid && self.locked_by_uuid != current_api_client_authorization.andand.uuid # When locked, progress fields cannot be updated by the wrong # dispatcher, even though it has admin privileges. @@ -495,6 +496,19 @@ class Container < ArvadosModel end end + def update_cr_logs + # If self.final?, this update is superfluous: the final log/output + # update will be done when handle_completed calls finalize! on + # each requesting CR. + return if self.final? || !self.log_changed? + leave_modified_by_user_alone do + ContainerRequest.where(container_uuid: self.uuid).each do |cr| + cr.update_collections(container: self, collections: ['log']) + cr.save! + end + end + end + def assign_auth if self.auth_uuid_changed? return errors.add :auth_uuid, 'is readonly'