Skip to content

Commit

Permalink
Merge pull request #175 from hnousiainen/htn_s3_dualstack_endpoints
Browse files Browse the repository at this point in the history
Use S3 dualstack endpoint by default

#175
  • Loading branch information
rikonen authored Mar 26, 2024
2 parents 0a958d3 + 451b588 commit 04c1b3f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions rohmu/object_storage/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class S3ObjectStorageConfig(StorageModel):
connect_timeout: Optional[str] = None
read_timeout: Optional[str] = None
aws_session_token: Optional[str] = Field(None, repr=False)
use_dualstack_endpoint: Optional[bool] = True
storage_type: Literal[StorageDriver.s3] = StorageDriver.s3

@root_validator(skip_on_failure=True)
Expand Down
3 changes: 3 additions & 0 deletions rohmu/object_storage/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def __init__(
read_timeout: Optional[float] = None,
notifier: Optional[Notifier] = None,
aws_session_token: Optional[str] = None,
use_dualstack_endpoint: Optional[bool] = True,
statsd_info: Optional[StatsdConfig] = None,
) -> None:
super().__init__(prefix=prefix, notifier=notifier, statsd_info=statsd_info)
Expand All @@ -137,6 +138,8 @@ def __init__(
if proxy_info:
proxy_url = get_proxy_url(proxy_info)
custom_config["proxies"] = {"https": proxy_url}
if use_dualstack_endpoint is True:
custom_config["use_dualstack_endpoint"] = True
self.s3_client = create_s3_client(
session=session,
config=botocore.config.Config(**custom_config),
Expand Down
5 changes: 4 additions & 1 deletion test/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def test_get_transfer_s3(
) -> None:
expected_config_arg = dict(config)
expected_config_arg.pop("notifier")
expected_botocore_config = {"proxies": {"https": "socks5://bob:[email protected]:16666"}}
expected_botocore_config = {
"proxies": {"https": "socks5://bob:[email protected]:16666"},
"use_dualstack_endpoint": True,
}
mock_config_model.return_value = S3ObjectStorageConfig(**expected_config_arg)

transfer_object = get_transfer(config)
Expand Down

0 comments on commit 04c1b3f

Please sign in to comment.