]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
OpenStack: if we get a 401 Unauthorized response, reauthenticate immediately.
authorDavid-Sarah Hopwood <david-sarah@jacaranda.org>
Thu, 21 Feb 2013 22:17:06 +0000 (22:17 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 4 Aug 2015 17:20:41 +0000 (18:20 +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.