diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-04-02 17:45:21 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-04-02 17:45:21 +0000 |
commit | ff7f7f474b634a921561aae1d0093a2881efcde4 (patch) | |
tree | 4cad822db2656bf18eae9d2b73c27c0c36220c23 | |
parent | 68cd88e22daeb388748f6766b0cb7bca465be0e4 (diff) | |
parent | c39290cb6e3a5c6e6e285ec82c7dcf6da174a7ea (diff) | |
download | swift-feature/ec.tar.gz |
Merge "Make sure COPY requests are routed correctly" into feature/ecerasure_code_dev_historyfeature/ec
-rw-r--r-- | swift/proxy/controllers/obj.py | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index f335d5011..8549cc1d2 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -229,18 +229,8 @@ class BaseObjectController(Controller): self.account_name, self.container_name, self.object_name) node_iter = self.app.iter_nodes(obj_ring, partition) - if policy and policy.policy_type != self.policy_type: - # when the GET portion of a COPY request is routed back through a - # controller we need to make sure the controller instance handling - # the request is the correct type for the policy. - controller = self.app.obj_controller_router[policy]( - self.app, self.account_name, self.container_name, - self.object_name) - else: - controller = self - - resp = controller._get_or_head_response(req, node_iter, partition, - policy) + resp = self._reroute(policy)._get_or_head_response( + req, node_iter, partition, policy) if ';' in resp.headers.get('content-type', ''): resp.content_type = clean_content_type( @@ -1072,6 +1062,19 @@ class BaseObjectController(Controller): headers, overrides=status_overrides) return resp + def _reroute(self, policy): + """ + For COPY requests we need to make sure the controller instance the + request is routed through the is the correct type for the policy. + """ + if policy and policy.policy_type != self.policy_type: + controller = self.app.obj_controller_router[policy]( + self.app, self.account_name, self.container_name, + self.object_name) + else: + controller = self + return controller + @public @cors_validation @delay_denial @@ -1088,6 +1091,7 @@ class BaseObjectController(Controller): self.account_name = dest_account del req.headers['Destination-Account'] dest_container, dest_object = check_destination_header(req) + source = '/%s/%s' % (self.container_name, self.object_name) self.container_name = dest_container self.object_name = dest_object @@ -1099,7 +1103,12 @@ class BaseObjectController(Controller): req.headers['Content-Length'] = 0 req.headers['X-Copy-From'] = quote(source) del req.headers['Destination'] - return self.PUT(req) + + container_info = self.container_info( + dest_account, dest_container, req) + dest_policy = POLICIES.get_by_index(container_info['storage_policy']) + + return self._reroute(dest_policy).PUT(req) @ObjectControllerRouter.register(REPL_POLICY) |