From 8e045d0de213457e97a943d0e6f75fe456c377e1 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Tue, 19 Feb 2019 13:14:34 -0800 Subject: [PATCH] versioned_writes: stop trying to catch HTTPPreconditionFailed * We just caught it to raise another one * On newer versions of python, we wouldn't actually catch anything, because HTTPPreconditionFailed is not an instance of BaseException -- it's a partial function application which when called will return an exception. Change-Id: Ia44e832e4198e75f3337884c4612f4e9fe3b9e0b --- swift/common/middleware/versioned_writes.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/swift/common/middleware/versioned_writes.py b/swift/common/middleware/versioned_writes.py index 82218eb837..74a541fb6c 100644 --- a/swift/common/middleware/versioned_writes.py +++ b/swift/common/middleware/versioned_writes.py @@ -258,18 +258,16 @@ class VersionedWritesContext(WSGIContext): def _listing_iter(self, account_name, lcontainer, lprefix, req): try: for page in self._listing_pages_iter(account_name, lcontainer, - lprefix, req.environ): + lprefix, req): for item in page: yield item except ListingIterNotFound: pass - except HTTPPreconditionFailed: - raise HTTPPreconditionFailed(request=req) except ListingIterError: raise HTTPServerError(request=req) def _in_proxy_reverse_listing(self, account_name, lcontainer, lprefix, - env, failed_marker, failed_listing): + req, failed_marker, failed_listing): '''Get the complete prefix listing and reverse it on the proxy. This is only necessary if we encounter a response from a @@ -300,7 +298,7 @@ class VersionedWritesContext(WSGIContext): try: for page in self._listing_pages_iter( account_name, lcontainer, lprefix, - env, marker, end_marker=failed_marker, reverse=False): + req, marker, end_marker=failed_marker, reverse=False): complete_listing.extend(page) except ListingIterNotFound: pass @@ -310,7 +308,7 @@ class VersionedWritesContext(WSGIContext): return reversed(complete_listing) def _listing_pages_iter(self, account_name, lcontainer, lprefix, - env, marker='', end_marker='', reverse=True): + req, marker='', end_marker='', reverse=True): '''Get "pages" worth of objects that start with a prefix. The optional keyword arguments ``marker``, ``end_marker``, and @@ -326,7 +324,7 @@ class VersionedWritesContext(WSGIContext): ''' while True: lreq = make_pre_authed_request( - env, method='GET', swift_source='VW', + req.environ, method='GET', swift_source='VW', path=quote('/v1/%s/%s' % (account_name, lcontainer))) lreq.environ['QUERY_STRING'] = \ 'prefix=%s&marker=%s' % (quote(lprefix), quote(marker)) @@ -341,7 +339,7 @@ class VersionedWritesContext(WSGIContext): if lresp.status_int == HTTP_NOT_FOUND: raise ListingIterNotFound() elif is_client_error(lresp.status_int): - raise HTTPPreconditionFailed() + raise HTTPPreconditionFailed(request=req) else: raise ListingIterError() @@ -361,7 +359,7 @@ class VersionedWritesContext(WSGIContext): # Apparently there's at least one pre-2.6.0 container server yield self._in_proxy_reverse_listing( account_name, lcontainer, lprefix, - env, marker, sublisting) + req, marker, sublisting) return marker = last_item