[ARVADOS] created: a04b28a606d52b066a00d4e960bf351df5cb9c6f

Git user git at public.curoverse.com
Fri Feb 24 11:01:14 EST 2017


        at  a04b28a606d52b066a00d4e960bf351df5cb9c6f (commit)


commit a04b28a606d52b066a00d4e960bf351df5cb9c6f
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Fri Feb 24 11:01:07 2017 -0500

    9277: arvados-cwl-runner sets "is_trashed" when directly setting output of container.

diff --git a/sdk/cwl/arvados_cwl/__init__.py b/sdk/cwl/arvados_cwl/__init__.py
index 024e9d0..36fe6ef 100644
--- a/sdk/cwl/arvados_cwl/__init__.py
+++ b/sdk/cwl/arvados_cwl/__init__.py
@@ -314,6 +314,10 @@ class ArvCwlRunner(object):
                                              body={
                                                  'output': self.final_output_collection.portable_data_hash(),
                                              }).execute(num_retries=self.num_retries)
+                self.api.collections().update(uuid=self.final_output_collection.manifest_locator(),
+                                              body={
+                                                  'is_trashed': True
+                                              }).execute(num_retries=self.num_retries)
             except Exception as e:
                 logger.info("Setting container output: %s", e)
         elif self.work_api == "jobs" and "TASK_UUID" in os.environ:

commit a6e4bcccfd646843ba35c9a79367f9bbd7124f8d
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Fri Feb 24 10:53:28 2017 -0500

    9277: Container output check must be unscoped to include trashed collections.

diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb
index ecaccf4..ea48ffa 100644
--- a/services/api/app/models/container.rb
+++ b/services/api/app/models/container.rb
@@ -269,10 +269,12 @@ class Container < ArvadosModel
     # that a container cannot "claim" a collection that it doesn't otherwise
     # have access to just by setting the output field to the collection PDH.
     if output_changed?
-      c = Collection.
-          readable_by(current_user).
-          where(portable_data_hash: self.output).
-          first
+      c = Collection.unscoped do
+        Collection.
+            readable_by(current_user).
+            where(portable_data_hash: self.output).
+            first
+      end
       if !c
         errors.add :output, "collection must exist and be readable by current user."
       end
diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb
index 3478535..6bb8fb0 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -96,7 +96,9 @@ class ContainerRequest < ArvadosModel
       else
         coll_name = "Container #{out_type} for request #{uuid}"
       end
-      manifest = Collection.unscoped.where(portable_data_hash: pdh).first.manifest_text
+      manifest = Collection.unscoped do
+        Collection.where(portable_data_hash: pdh).first.manifest_text
+      end
       begin
         coll = Collection.create!(owner_uuid: owner_uuid,
                                   manifest_text: manifest,
diff --git a/services/api/test/fixtures/collections.yml b/services/api/test/fixtures/collections.yml
index cda7515..6db6d78 100644
--- a/services/api/test/fixtures/collections.yml
+++ b/services/api/test/fixtures/collections.yml
@@ -284,6 +284,21 @@ collection_expires_in_future:
   manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:expired\n"
   name: collection_expires_in_future
 
+unique_expired_collection:
+  uuid: zzzzz-4zz18-mto52zx1s7sn3jk
+  portable_data_hash: 4ad199f90029935844dc3f098f4fca2a+49
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  created_at: 2014-02-03T17:22:54Z
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f
+  modified_at: 2014-02-03T17:22:54Z
+  updated_at: 2014-02-03T17:22:54Z
+  is_trashed: true
+  trash_at: 2001-01-01T00:00:00Z
+  delete_at: 2038-01-01T00:00:00Z
+  manifest_text: ". 29d7797f1888013986899bc9083783fa+3 0:3:expired\n"
+  name: unique_expired_collection
+
 # a collection with a log file that can be parsed by the log viewer
 # This collection hash matches the following log text:
 #    2014-01-01_12:00:01 zzzzz-8i9sb-abcdefghijklmno 0  log message 1
diff --git a/services/api/test/unit/container_test.rb b/services/api/test/unit/container_test.rb
index 03944d6..4177de4 100644
--- a/services/api/test/unit/container_test.rb
+++ b/services/api/test/unit/container_test.rb
@@ -506,4 +506,17 @@ class ContainerTest < ActiveSupport::TestCase
     end
   end
 
+  test "can set trashed output on running container" do
+    c, _ = minimal_new
+    set_user_from_auth :dispatch1
+    c.lock
+    c.update_attributes! state: Container::Running
+
+    output = Collection.unscoped.find_by_uuid('zzzzz-4zz18-mto52zx1s7sn3jk')
+
+    assert output.is_trashed
+    assert c.update_attributes output: output.portable_data_hash
+    assert c.update_attributes! state: Container::Complete
+  end
+
 end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list