2752: arv-put shouldn't resume from expired Keep locators.
authorBrett Smith <brett@curoverse.com>
Mon, 26 May 2014 11:31:07 +0000 (07:31 -0400)
committerBrett Smith <brett@curoverse.com>
Mon, 26 May 2014 12:12:28 +0000 (08:12 -0400)
sdk/python/arvados/collection.py
sdk/python/tests/test_collections.py

index 814bd75a1ed0d0ccaad6c362385eac406660773e..7b38ccd180444a92a8bd1c3684b1082b49568f4c 100644 (file)
@@ -396,6 +396,10 @@ class ResumableCollectionWriter(CollectionWriter):
                 attr_value = attr_class(attr_value)
             setattr(writer, attr_name, attr_value)
         # Check dependencies before we try to resume anything.
+        if any(KeepLocator(ls).permission_expired()
+               for ls in writer._current_stream_locators):
+            raise errors.StaleWriterStateError(
+                "locators include expired permission hint")
         writer.check_dependencies()
         if state['_current_file'] is not None:
             path, pos = state['_current_file']
index bb64c77e0abddd6a388292a41467d48d3cc88850..4d1e1505d6e8e33835c73b12f27b8bea7a06b12e 100644 (file)
@@ -585,6 +585,20 @@ class ArvadosCollectionsTest(ArvadosKeepLocalStoreTestCase):
                               TestResumableWriter.from_state,
                               cwriter.last_state())
 
+    def test_resume_fails_with_expired_locator(self):
+        cwriter = TestResumableWriter()
+        with self.make_test_file() as testfile:
+            cwriter.write_file(testfile.name, 'test')
+            cwriter.finish_current_stream()
+            state = cwriter.last_state()
+            # Get the last locator, remove any permission hint, and add
+            # an expired one.
+            new_loc = state['_current_stream_locators'][-1].split('+A', 1)[0]
+            state['_current_stream_locators'][-1] = "{}+A{}@10000000".format(
+                new_loc, 'a' * 40)
+            self.assertRaises(arvados.errors.StaleWriterStateError,
+                              TestResumableWriter.from_state, state)
+
     def test_successful_resumes(self):
         # FIXME: This is more of an integration test than a unit test.
         cwriter = TestResumableWriter()