]> 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>
Wed, 9 Apr 2014 00:33:56 +0000 (01:33 +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 d59849c3a5cc33ddd346c42aec31e3046209b00e..a7e2aa1b53826165d9e884415c6dc7ea80a158c1 100644 (file)
@@ -832,10 +832,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])
@@ -852,8 +854,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)