Yehuda Sadeh
unread,Jun 14, 2012, 4:30:33 PM6/14/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to boto...@googlegroups.com
This is a new issue that started happening on 2.5.0. The problem is
that on 400 responses (from S3), the error_code is not getting set.
The culprit apparently is the following:
@@ -764,6 +780,13 @@ class AWSAuthConnection(object):
msg += 'Retrying in %3.1f seconds' % next_sleep
boto.log.debug(msg)
body = response.read()
+ elif self._credentials_expired(response):
+ # The same request object is used so the security token and
+ # access key params are cleared because they are no longer
+ # valid.
+ request.params = original_params.copy()
+ request.headers = original_headers.copy()
+ self._renew_credentials()
elif response.status < 300 or response.status >= 400 or \
not location:
self.put_http_connection(request.host, self.is_secure,
...
@@ -160,6 +172,19 @@ class S3Connection(AWSAuthConnection):
else:
return ['s3']
+ def _credentials_expired(self, response):
+ if response.status != 400:
+ return False
+ try:
+ for event, node in ElementTree.iterparse(response,
+ events=['start']):
+ if node.tag.endswith('Code'):
+ if node.text == 'ExpiredToken':
+ return True
+ except XMLParseError:
+ return False
+ return False
+
Basically, calling _credentials_expired(response) empties the response
body, and that happens before returning the response. I'm not sure
what would be the best fix for that.
Yehuda