]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
OpenStack: if we get a 401 Unauthorized response, reauthenticate immediately.
authorDaira Hopwood <daira@jacaranda.org>
Thu, 21 Feb 2013 22:17:06 +0000 (22:17 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Fri, 16 Oct 2015 16:45:30 +0000 (17:45 +0100)
Signed-off-by: David-Sarah Hopwood <david-sarah@jacaranda.org>
src/allmydata/storage/backends/cloud/openstack/openstack_container.py

index 4e52dc0749f2bd96b67c2390509358f06ccf5539..7aedf1753cb556b1f1582d0d1f36ff31cc7d0687 100644 (file)
@@ -9,6 +9,7 @@ from allmydata.util.deferredutil import eventually_callback, eventually_errback
 from twisted.internet.protocol import Protocol
 from twisted.web.client import Agent, FileBodyProducer, ResponseDone
 from twisted.web.http_headers import Headers
+from twisted.web.http import UNAUTHORIZED
 
 from zope.interface import implements, Interface
 
@@ -230,6 +231,10 @@ class AuthenticationClient(object):
         d.addCallback(lambda ign: self._auth_info)
         return d
 
+    def invalidate(self):
+        self._auth_info = None
+        self._reauthenticate()
+
     def _authenticate(self):
         (method, url, request_headers, body, need_response_body) = self._authenticator.make_auth_request()
 
@@ -311,6 +316,14 @@ class OpenStackContainer(ContainerRetryMixin):
         return "%s/%s/%s" % (auth_info.public_storage_url, urllib.quote(self._container_name, safe=''),
                              urllib.quote(object_name))
 
+    def _react_to_error(self, response_code):
+        if response_code == UNAUTHORIZED:
+            # Invalidate auth_info and retry.
+            self._auth_client.invalidate()
+            return True
+        else:
+            return ContainerRetryMixin._react_to_error(self, response_code)
+
     def _create(self):
         """
         Create this container.