-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add request_payer parameter to sync, cp, and rm subcommands #3016
Conversation
I applied this patch and
|
@iandees Are both buckets "requester pays"? Did you run the command from your local machine? Also, were there any "files" in the target "folder"? |
The from bucket is requester pays in eu-central-1 ( |
@iandees Thank you. Will check it. |
Running a sync to my local directory works, so it is likely that I didn't set up permissions for the destination bucket properly:
|
Yep, I fixed my permissions (I was using the wrong AWS profile when calling awscli) and this patch works. I hope it gets merged in! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request. The interface and approach looks fine to me. I just had some comments related to cleaning up how it gets plumbed in to make more consistent with how arguments have been added in the past. The only other thing that I would really like to see is tests. Specifically it would be great to have:
-
Unit tests for the functionality added to
BucketLister
andRequestParamsMapper
-
Functional tests to make sure all of the commands properly map in the
RequestPayer
method gets mapped in correctly. -
A couple of integration tests for sanity sake to make sure that it works end to end when hitting the s3 servers. I would imagine you would have one case for
cp
,sync
, and mayberm
.
Given there is some work left to get the PR in a place we would be comfortable merging, we would be willing to build on top of your PR and champion it till gets merged. However if you want to continue working on it till completion, we would happily continue giving feedback till it gets merged. Let us know and thanks again!
@@ -357,10 +357,12 @@ def __init__(self, client, date_parser=_date_parser): | |||
self._client = client | |||
self._date_parser = date_parser | |||
|
|||
def list_objects(self, bucket, prefix=None, page_size=None): | |||
def list_objects(self, bucket, prefix=None, page_size=None, request_payer=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that I would prefer that we made this more generalized such as an extra_args
that takes a dictionary of extra arguments that get passed in. That way if we want to pass information like Delimeter
or UrlEncoding
it would be easier.
@@ -725,7 +725,7 @@ class CpCommand(S3TransferCommand): | |||
"or <S3Uri> <S3Uri>" | |||
ARG_TABLE = [{'name': 'paths', 'nargs': 2, 'positional_arg': True, | |||
'synopsis': USAGE}] + TRANSFER_ARGS + \ | |||
[METADATA, METADATA_DIRECTIVE, EXPECTED_SIZE, RECURSIVE] | |||
[METADATA, METADATA_DIRECTIVE, EXPECTED_SIZE, RECURSIVE, REQUEST_PAYER] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the cp
and sync
, it would be great if this can be added to the TRANSFER_ARGS
list so it will get included in the mv
command as well and it does not have to be explicitly added to each list for those commands.
rgen_request_parameters = { | ||
'RequestPayer': self.parameters.get('request_payer'), | ||
} | ||
rgen_kwargs['request_parameters'] = rgen_request_parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for the request parameters that get passed to the FileGenerator's
, I think I would prefer to do something more like this:
aws-cli/awscli/customizations/s3/subcommands.py
Lines 999 to 1007 in 9cdd69c
RequestParamsMapper.map_head_object_params( | |
fgen_head_object_params, self.parameters) | |
if paths_type == 's3s3': | |
RequestParamsMapper.map_head_object_params( | |
fgen_head_object_params, { | |
'sse_c': self.parameters.get('sse_c_copy_source'), | |
'sse_c_key': self.parameters.get('sse_c_copy_source_key') | |
} | |
) |
where we:
-
Add a key
ListObjects
to both thefgen_request_parameters
andrgen_request_parameters
parameters that is an empty dictionary. -
Use the
RequestParamsMapper
class to map theRequesterPayer
parameter into those parameter dictionaries based on if the argument was provided to the commandline.
I am mainly suggesting this because:
- There is already precedence with how we set the
HeadObject
key in therequest_parameters
- It will make it easier to add future parameters for
ListObjects
.
fgen_head_object_params = {} | ||
fgen_request_parameters['HeadObject'] = fgen_head_object_params | ||
fgen_kwargs['request_parameters'] = fgen_request_parameters | ||
|
||
rgen_request_parameters = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question that I have is for a cross-copy sync
command that has one bucket that uses requester pays and the other one that does not use requester pays, is there any unintentional side effects of passing RequestPayer
to a ListObjects
(or any other) call for the bucket where request payer is not enabled. I do not think so but I would need to double check this. Just wanted to see if you ran into this at all.
@kyleknap I was waiting for detailed feedback from you, guys :) Thank you. |
We urgently need this as well. Please see email I sent your github email about this. |
Hey @sp-niemand if you do not mind, I am going to start working on pushing this to completion. There is fair amount of users now that are eagerly waiting for this to get merged in. Let me know if there is any issues in me doing so. |
@kyleknap Yes, please. |
No worries. Thanks for doing the initial stab at this. I will build on top of your commit. |
@kyleknap |
@aquanyc I just submitted a PR that added the necessary updates for this feature: #3147. Once that goes through reviews and feedback is incorporated, it will be merged and part of the subsequent CLI release. @sp-niemand I kept your commit but decided to open up a new PR when sending in my changes. I mainly did this because I did a rebase on the develop branch so I did not want to force push to your branch. I would appreciate it if you can take a look at it as well to make sure I did not miss anything. I'm closing out this PR in favor of: #3147. For those watching this PR, feel free to hop over to the PR I just recently opened and try the implementation out as that PR should be the one that gets merged in the end. |
Adds support for Requester Pays buckets to some
aws s3
subcommands.Addresses several related issues:
#2845
#2557
Also this (?):
#797