← Back to team overview

duplicity-team team mailing list archive

[Merge] lp:~mterry/duplicity/u1-fixes into lp:duplicity

 

Michael Terry has proposed merging lp:~mterry/duplicity/u1-fixes into lp:duplicity.

Requested reviews:
  duplicity-team (duplicity-team)

For more details, see:
https://code.launchpad.net/~mterry/duplicity/u1-fixes/+merge/70359

This branch fixes some issues with the Ubuntu One backend.

 - Adds support for status code 503 (temporary load on server) by delaying 30s when it sees it before the next retry.

 - Adds support for status code 507 (disk full) instead of treating 500 as disk full.

 - Includes Oops-ID in message shown to user, so that the U1 team can do something about a given error.
-- 
https://code.launchpad.net/~mterry/duplicity/u1-fixes/+merge/70359
Your team duplicity-team is requested to review the proposed merge of lp:~mterry/duplicity/u1-fixes into lp:duplicity.
=== modified file 'duplicity/backend.py'
--- duplicity/backend.py	2011-06-17 06:21:42 +0000
+++ duplicity/backend.py	2011-08-03 19:51:35 +0000
@@ -43,6 +43,7 @@
 from duplicity.util import exception_traceback
 
 from duplicity.errors import BackendException
+from duplicity.errors import TemporaryLoadException
 from duplicity.errors import ConflictingScheme
 from duplicity.errors import InvalidBackendURL
 from duplicity.errors import UnsupportedBackendScheme
@@ -310,6 +311,8 @@
                          % (n, e.__class__.__name__, str(e)))
                 log.Debug("Backtrace of previous error: %s"
                           % exception_traceback())
+                if isinstance(e, TemporaryLoadException):
+                    time.sleep(30) # wait a bit before trying again
         # Now try one last time, but fatal-log instead of raising errors
         kwargs = {"raise_errors" : False}
         return fn(*args, **kwargs)

=== modified file 'duplicity/backends/u1backend.py'
--- duplicity/backends/u1backend.py	2011-07-29 12:56:02 +0000
+++ duplicity/backends/u1backend.py	2011-08-03 19:51:35 +0000
@@ -20,7 +20,7 @@
 
 import duplicity.backend
 from duplicity.backend import retry
-from duplicity.errors import BackendException
+from duplicity.errors import BackendException, TemporaryLoadException
 
 def ensure_dbus():
     # GIO requires a dbus session bus which can start the gvfs daemons
@@ -114,7 +114,7 @@
             code = log.ErrorCode.backend_permission_denied
         elif status == 404:
             code = log.ErrorCode.backend_not_found
-        elif status == 500: # wish this were a more specific error
+        elif status == 507:
             code = log.ErrorCode.backend_no_space
         else:
             code = log.ErrorCode.backend_error
@@ -124,13 +124,18 @@
         extra = ' '.join([util.escape(x) for x in [file1, file2] if x])
         extra = ' '.join([op, extra])
         msg = _("Got status code %s") % status
+        if headers[0].get('x-oops-id') is not None:
+            msg += '\nOops-ID: %s' % headers[0].get('x-oops-id')
         if headers[0].get('content-type') == 'application/json':
             node = json.loads(headers[1])
             if node.get('error'):
                 msg = node.get('error')
 
         if raise_error:
-            raise BackendException(msg)
+            if status == 503:
+                raise TemporaryLoadException(msg)
+            else:
+                raise BackendException(msg)
         else:
             log.FatalError(msg, code, extra)
 

=== modified file 'duplicity/errors.py'
--- duplicity/errors.py	2009-04-01 15:07:45 +0000
+++ duplicity/errors.py	2011-08-03 19:51:35 +0000
@@ -70,4 +70,10 @@
     """
     pass
 
+class TemporaryLoadException(BackendException):
+    """
+    Raised to indicate a temporary issue on the backend.
+    Duplicity should back off for a bit and try again.
+    """
+    pass
 


Follow ups