Skip to content
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

Does not work with custom endpoint_url & region_name #42

Open
M0dM opened this issue Dec 20, 2019 · 1 comment · May be fixed by #43
Open

Does not work with custom endpoint_url & region_name #42

M0dM opened this issue Dec 20, 2019 · 1 comment · May be fixed by #43

Comments

@M0dM
Copy link

M0dM commented Dec 20, 2019

Hi,

I am trying to make KEV work with minio: https://github.com/minio/minio
I got this error:

    File ~/.local/share/virtualenvs/myvenv/lib/python3.8/site-packages/kev/backends/s3/db.py", line 25, in __init__
        boto3.Session(**session_kwargs)
    TypeError: __init__() got an unexpected keyword argument 'endpoint_url'

My config is this one :

    's3': {
        'backend': 'kev.backends.s3.db.S3DB',
        'connection': {
            'bucket': 'mybucketname',
            'endpoint_url': 'http://localhost:9000'  # The port of my minio local deployment
        }
    }

I had dig a little bit inside the code and found the issue:
As described here : https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html#boto3.session.Session

boto3.Session reference attributes (no endpoint_url):

    class boto3.session.Session(aws_access_key_id=None, aws_secret_access_key=None, aws_session_token=None, region_name=None, botocore_session=None, profile_name=None)

Boto3 Session does not support endpoint_url argument.
This argument must be added when creating s3 boto resource.

What could be done is something like this in kev.backends.s3.db.S3DB class constructor:

    def __init__(self,**kwargs):
        #
        session_kwargs = {k: v for k, v in kwargs.items() if k in
                          self.session_kwargs}
        endpoint_url = None
        if 'endpoint_url' in session_kwargs.keys():
            endpoint_url =  session_kwargs['endpoint_url']   
            del(session_kwargs['endpoint_url'])
        if len(session_kwargs.keys()) > 0:
            boto3.Session(**session_kwargs)

        self._db = boto3.resource('s3', endpoint_url=endpoint_url)
        self.bucket = kwargs['bucket']
        self._indexer = self._db.Bucket(self.bucket)

boto3.resource reference attributes (existing endpoint_url kwarg):

    resource(service_name, region_name=None, api_version=None, use_ssl=True, verify=None, endpoint_url=None, aws_access_key_id=None, aws_secret_access_key=None, aws_session_token=None, config=None)[source]

endpoint_url default value is None, then this code should always be ok.

What do you think about this fix / workaround ?

Edit: We should add support to region_name also...

@M0dM M0dM changed the title Does not work with custom endpoint_url Does not work with custom endpoint_url & region_name Dec 20, 2019
@bjinwright
Copy link
Member

Endpoint URL is supported as of 0.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants