]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Retry cloud HTTP requests on *any* exception (the list is long, and hard to make...
authorItamar Turner-Trauring <itamar@futurefoundries.com>
Tue, 26 Mar 2013 19:02:11 +0000 (15:02 -0400)
committerDaira Hopwood <daira@jacaranda.org>
Fri, 16 Oct 2015 16:50:55 +0000 (17:50 +0100)
src/allmydata/storage/backends/cloud/cloud_common.py
src/allmydata/test/test_storage.py

index ce3d21567f6da4fe1485fda2095711285ae86eb3..657d96622f86d78a09b68c3dd94da950754177d3 100644 (file)
@@ -340,7 +340,9 @@ class ContainerRetryMixin:
 
     Subclasses should define:
       ServiceError:
-          The error class to trap (CloudServiceError or similar).
+          An exceptions class with meaningful status codes that can be
+          filtered using _react_to_error. Other exceptions will cause
+          unconditional retries.
 
     and can override:
       _react_to_error(self, response_code):
@@ -366,8 +368,6 @@ class ContainerRetryMixin:
         return d
 
     def _handle_error(self, f, trynum, first_err_and_tb, description, operation, *args, **kwargs):
-        f.trap(self.ServiceError, TimeoutError)
-
         # Don't use f.getTracebackObject() since a fake traceback will not do for the 3-arg form of 'raise'.
         # tb can be None (which is acceptable for 3-arg raise) if we don't have a traceback.
         tb = getattr(f, 'tb', None)
index df7615f80f7b15215261de51aaf9dcdf11323c25..c27aabb081591e79e56a49100b1033293687275e 100644 (file)
@@ -839,10 +839,12 @@ class ContainerRetryTests(unittest.TestCase, CloudStorageBackendMixin):
         second.callback(done)
         self.assertEqual(result, [done])
 
-    def test_retry_timeout(self):
+    def test_retry_random_exception(self):
         """
-        If an HTTP connection fails with a timeout, retry.
+        If a HTTP request fails with any exception at all, retry.
         """
+        class NewException(Exception):
+            pass
         first, second = defer.Deferred(), defer.Deferred()
         self.container._http_request = mock.create_autospec(
             self.container._http_request, side_effect=[first, second])
@@ -859,8 +861,7 @@ class ContainerRetryTests(unittest.TestCase, CloudStorageBackendMixin):
             body=None, need_response_body=True)
 
         # First response fails:
-        from twisted.internet.error import TimeoutError
-        first.errback(TimeoutError())
+        first.errback(NewException())
         self.assertFalse(result, result)
         self.assertEqual(self.container._http_request.call_count, 1)
         self.reactor.advance(0.1)