Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pfs_middleware: Delay clearing container info
Browse files Browse the repository at this point in the history
... until *after* we've actually made backend requests. See
openstack/swift@244d7de and
https://bugs.launchpad.net/swift/+bug/1715177
tipabu committed Oct 1, 2020
1 parent 2cfae94 commit d62ad4d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pfs_middleware/pfs_middleware/middleware.py
Original file line number Diff line number Diff line change
@@ -1239,13 +1239,13 @@ def put_container(self, ctx):
head_response)
except utils.RpcError as err:
if err.errno == pfs_errno.NotFoundError:
clear_info_cache(None, ctx.req.environ, ctx.account_name,
container=ctx.container_name)
self.rpc_call(ctx, rpc.put_container_request(
container_path,
"",
serialize_metadata({
k: v for k, v in new_metadata.items() if v})))
clear_info_cache(None, ctx.req.environ, ctx.account_name,
container=ctx.container_name)
return swob.HTTPCreated(request=req)
else:
raise
@@ -1255,10 +1255,10 @@ def put_container(self, ctx):
old_metadata, new_metadata)
raw_merged_metadata = serialize_metadata(merged_metadata)

clear_info_cache(None, ctx.req.environ, ctx.account_name,
container=ctx.container_name)
self.rpc_call(ctx, rpc.put_container_request(
container_path, raw_old_metadata, raw_merged_metadata))
clear_info_cache(None, ctx.req.environ, ctx.account_name,
container=ctx.container_name)

return swob.HTTPAccepted(request=req)

@@ -1299,19 +1299,20 @@ def post_container(self, ctx):
req.headers.clear()
req.headers.update(new_metadata)

clear_info_cache(None, req.environ, ctx.account_name,
container=ctx.container_name)
self.rpc_call(ctx, rpc.post_request(
container_path, raw_old_metadata, raw_merged_metadata))
clear_info_cache(None, req.environ, ctx.account_name,
container=ctx.container_name)

return swob.HTTPNoContent(request=req)

def delete_container(self, ctx):
# Turns out these are the same RPC with the same error handling, so
# why not?
response = self.delete_object(ctx)
clear_info_cache(None, ctx.req.environ, ctx.account_name,
container=ctx.container_name)
return self.delete_object(ctx)
return response

def _get_listing_limit(self, req, default_limit):
raw_limit = req.params.get('limit')

0 comments on commit d62ad4d

Please sign in to comment.