s3: inline bucket region caching (#6406)

This commit is contained in:
Batuhan Taskaya
2021-09-06 12:20:52 +03:00
committed by GitHub
parent db93709f21
commit 348dfc0496
2 changed files with 11 additions and 2 deletions
+1
View File
@@ -155,6 +155,7 @@ SCHEMA = {
"grant_read_acp": str,
"grant_write_acp": str,
"grant_full_control": str,
"cache_regions": bool,
**REMOTE_COMMON,
},
"gs": {
+10 -2
View File
@@ -68,12 +68,12 @@ class BaseS3FileSystem(ObjectFSWrapper):
self._transfer_config = None
config_path = os.environ.get("AWS_CONFIG_FILE", _AWS_CONFIG_PATH)
if not os.path.exists(config_path):
return None
return {}
config = load_config(config_path)
profile_config = config["profiles"].get(profile or "default")
if not profile_config:
return None
return {}
s3_config = profile_config.get("s3", {})
return self._split_s3_config(s3_config)
@@ -123,6 +123,14 @@ class BaseS3FileSystem(ObjectFSWrapper):
if shared_creds:
os.environ.setdefault("AWS_SHARED_CREDENTIALS_FILE", shared_creds)
if (
client["region_name"] is None
and session_config["s3"].get("region_name") is None
and os.getenv("AWS_REGION") is None
):
# Enable bucket region caching
login_info["cache_regions"] = config.get("cache_regions", True)
config_path = config.get("configpath")
if config_path:
os.environ.setdefault("AWS_CONFIG_FILE", config_path)