From f65f355cff150cda3c1e4281dcbe3af3d5e0c63c Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Tue, 10 Sep 2019 11:25:58 -0400 Subject: [PATCH] 15499: Only create additional log collection when container is Complete Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- services/api/app/models/container_request.rb | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb index 7aa82335f7..5a78181473 100644 --- a/services/api/app/models/container_request.rb +++ b/services/api/app/models/container_request.rb @@ -156,20 +156,22 @@ class ContainerRequest < ArvadosModel container = Container.find_by_uuid(container_uuid) update_collections(container: container) - log_col = Collection.where(portable_data_hash: container.log).first - if log_col - # Need to save collection - completed_coll = Collection.new( - owner_uuid: self.owner_uuid, - name: "Container log for container #{container_uuid}", - properties: { - 'type' => 'log', - 'container_request' => self.uuid, - 'container_uuid' => container_uuid, - }, - portable_data_hash: log_col.portable_data_hash, - manifest_text: log_col.manifest_text) - completed_coll.save_with_unique_name! + if container.state == Container::Complete + log_col = Collection.where(portable_data_hash: container.log).first + if log_col + # Need to save collection + completed_coll = Collection.new( + owner_uuid: self.owner_uuid, + name: "Container log for container #{container_uuid}", + properties: { + 'type' => 'log', + 'container_request' => self.uuid, + 'container_uuid' => container_uuid, + }, + portable_data_hash: log_col.portable_data_hash, + manifest_text: log_col.manifest_text) + completed_coll.save_with_unique_name! + end end update_attributes!(state: Final) -- 2.30.2