-
Notifications
You must be signed in to change notification settings - Fork 76
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
[SVCS-826] S3 Compatablilty #351
base: develop
Are you sure you want to change the base?
[SVCS-826] S3 Compatablilty #351
Conversation
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.
What's the purpose of this PR? Looks related to your S3-like provider update?
I see some of the API calls are replaced with client library code, which is a major change. What's the primary reason? How does this impact our async requests?
Yep that's true, its related to s3-compat. Replacing the calls with client library is because the signature stuff in boto2 is delusional. the signature stuff in boto3 works as intended. It is going to be synchronous as written now, but there's two options - |
boto2 causes lots of problems, and trying to use both is trying. Use boto3 for all s3 operations.
Upgrades boto2 to boto3. This required some implementations of operations to change because of some inflexibility inside of boto - It likes to do it the boto way, but using some of the internals, to generate signed urls for example, is difficult to call in isolation. In the interest of getting it implemented sooner than later, we use the boto way of doing some things rather than making our own requests manually.
Removes some code that was written during trying to get the provider working. This code was exploratory and does not work.
Finishes updates to the sign_url functions to allow use with boto3's `generate_presigned_url`
waterbutler/providers/s3/provider.py
Outdated
|
||
async def revisions(self, path, **kwargs): | ||
"""Get past versions of the requested key | ||
|
||
:param str path: The path to a key | ||
:rtype list: | ||
""" | ||
await self._check_region() | ||
|
||
query_params = {'prefix': path.path, 'delimiter': '/', 'versions': ''} | ||
url = functools.partial(self.bucket.generate_url, settings.TEMP_URL_SECS, 'GET', query_parameters=query_params) |
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.
This needs to be fixed
@@ -1,6 +1,7 @@ | |||
agent==0.1.2 | |||
aiohttp==0.18.2 | |||
git+https://github.com/felliott/boto.git@feature/gen-url-query-params-6#egg=boto |
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.
Need to remove old boto
@@ -187,12 +188,16 @@ def size(self): | |||
def at_eof(self): | |||
return self.inner.at_eof() | |||
|
|||
def tell(self): | |||
return self.offset | |||
|
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.
Not strictly necessary, but was needed for a transient implementation. Still technically correct and simply makes our streams more stream-y.
@@ -105,15 +105,17 @@ def _async_retry(func): | |||
)) | |||
|
|||
|
|||
def normalize_datetime(date_string): | |||
if date_string is None: | |||
def normalize_datetime(date): |
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.
not always a string, so saying date_str here is a little misleading.
|
||
import xmltodict | ||
|
||
import xml.sax.saxutils | ||
|
||
#import aioboto3 | ||
from boto import config as boto_config | ||
from boto.compat import BytesIO # type: ignore | ||
from boto.utils import compute_md5 | ||
from boto.auth import get_auth_handler | ||
from boto.s3.connection import S3Connection | ||
from boto.s3.connection import OrdinaryCallingFormat |
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.
Need to remove old boto
:param HttpMethod: The http method to use on the generated url. By | ||
default, the http method is whatever is used in the method's model. | ||
:returns: The presigned url | ||
""" |
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.
Add another comment here explaining the patch better
# to supply the client with a string of the region name. First we | ||
# make a temporary client in order to get that string. We put the | ||
# client creation inside a lmabda so its easier to call twice. | ||
# This must be a lambda an *not* a partial, because we want the |
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.
This isn't really relevant here.
# if kwargs.get('displayName'): | ||
# get_kwargs['ResponseContentDisposition'] = 'attachment; filename*=UTF-8\'\'{}'.format(parse.quote(kwargs['displayName'])) | ||
# else: | ||
# get_kwargs['ResponseContentDisposition'] = 'attachment' |
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.
Remove if dead
Purpose
This PR enables users to connect any s3 compatible storage provider to their OSF account using the s3 addon.
Changes
Rewrites all s3 provider operations to use boto3 (boto2 has issues signing urls that will work properly with minio)
QA Notes
Ensure that users can connect s3-compatible providers
#Documentation
Side Effects
Users modifying an account will necessarily modify that account for any other user that also has connected this account. (This is already a behaviour experienced using the 'connect or reauthorize dialog)
Ticket
https://openscience.atlassian.net/browse/SVCS-826