sdsc-ordes / modos-api

Python API to manage multi-omics digital objects
https://sdsc-ordes.github.io/modos-api
Apache License 2.0
0 stars 0 forks source link

allow virtual host-style buckets for s3 #63

Closed cmdoret closed 4 months ago

cmdoret commented 4 months ago

The current setup assumes s3 bucket follows a path-style pattern: http://domain/bucket/path. We should also support virtual host style, which is becoming standard: http://bucket.domain/path.

cmdoret commented 4 months ago

botocore supports a config field addressing_style, which can be set to auto.

This field is forwarded from s3fs as follows:

fs = s3fs.S3FileSystem(endpoint_url='http://minio-domain:9000', anon=True, config_kwargs={'s3': {'addressing_style': 'auto'}})

fs.ls('bucket-name')

Note to reproduce this locally with minio, one needs to enable virtual-host-style buckets with minio as follows:

$ echo "127.0.0.1   minio-domain bucket-name.minio-domain" >> /etc/hosts

$ docker run -e 'MINIO_DOMAIN=minio-domain' --rm -p 9000:9000 -p 9001:9001 docker.io/bitnami/minio:2024

As long as we keep path separate from endpoint, s3fs should take care of building the url as needed(?)

cmdoret commented 4 months ago

both virtual and path addressing styles work on minio, however 'auto' defaults to path according to botocore docs.

Auto is supposed to probe the s3 server configuration to detect preferred addressing style.

Proposed solution: explicitely set the addressing style based on environment variable (but defaulting to auto), to allow overriding addressing style on client and server.

Requirements: