Repository navigation
feat(presto-clp): Add support for custom S3 endpoint URLs and buckets. #1917
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
Changes from 5 commits
2be8401
6298bc4
9319488
8511646
f8ee2e5
fc402c9
064feb8
db8b8f7
b1a0881
469aa3b
ae56023
8520ff9
90cc4b5
a080de5
ed7feb7
c859616
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,9 @@ | |
| PRESTO_QUERY_MEMORY_RATIO = 0.5 | ||
| PRESTO_SYSTEM_MEMORY_RATIO = 0.9 | ||
|
|
||
| # S3 URL constant | ||
| AWS_ENDPOINT = "amazonaws.com" | ||
|
|
||
| # Set up console logging | ||
| logging_console_handler = logging.StreamHandler() | ||
| logging_formatter = logging.Formatter( | ||
|
|
@@ -260,9 +263,6 @@ def _add_clp_s3_env_vars( | |
| s3_bucket = _get_required_config_value( | ||
| clp_config, f"{s3_config_key}.bucket", clp_config_file_path | ||
| ) | ||
| s3_region_code = _get_required_config_value( | ||
| clp_config, f"{s3_config_key}.region_code", clp_config_file_path | ||
| ) | ||
|
|
||
| aws_auth_key = f"{s3_config_key}.aws_authentication" | ||
| aws_auth_type_key = f"{aws_auth_key}.type" | ||
|
|
@@ -284,15 +284,38 @@ def _add_clp_s3_env_vars( | |
| except KeyError: | ||
| return False | ||
|
|
||
| s3_endpoint_url = _get_config_value(clp_config, f"{s3_config_key}.endpoint_url") | ||
| s3_region_code = _get_config_value(clp_config, f"{s3_config_key}.region_code") | ||
| s3_end_point = _handle_s3_endpoint_url(s3_endpoint_url, s3_region_code, s3_bucket) | ||
|
|
||
| env_vars["PRESTO_WORKER_CLPPROPERTIES_S3_AUTH_PROVIDER"] = "clp_package" | ||
| env_vars["PRESTO_WORKER_CLPPROPERTIES_S3_ACCESS_KEY_ID"] = s3_access_key_id | ||
| s3_end_point = f"https://{s3_bucket}.s3.{s3_region_code}.amazonaws.com/" | ||
| env_vars["PRESTO_WORKER_CLPPROPERTIES_S3_BUCKET"] = s3_bucket | ||
| env_vars["PRESTO_WORKER_CLPPROPERTIES_S3_END_POINT"] = s3_end_point | ||
| env_vars["PRESTO_WORKER_CLPPROPERTIES_S3_SECRET_ACCESS_KEY"] = s3_secret_access_key | ||
|
|
||
| return True | ||
|
|
||
|
|
||
| def _handle_s3_endpoint_url( | ||
|
20001020ycx marked this conversation as resolved.
Resolved
|
||
| endpoint_url: str | None, region_code: str | None, bucket_name: str | ||
| ) -> str: | ||
| """ | ||
| Returns the S3 endpoint URL, or constructs an AWS S3 URL if not provided. | ||
|
|
||
| :param endpoint_url: | ||
|
20001020ycx marked this conversation as resolved.
Resolved
|
||
| :param region_code: AWS region code, or None. | ||
|
20001020ycx marked this conversation as resolved.
Resolved
|
||
| :param bucket_name: S3 bucket name (used to construct AWS S3 URL). | ||
|
20001020ycx marked this conversation as resolved.
Resolved
|
||
| :return: The S3 endpoint URL. | ||
| """ | ||
| if endpoint_url is not None: | ||
| return endpoint_url | ||
|
20001020ycx marked this conversation as resolved.
Resolved
20001020ycx marked this conversation as resolved.
Resolved
|
||
|
|
||
| if region_code is None: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand this is needed to support non-AWS S3 endpoints. However, omitting a region is non-standard for AWS S3. Historically, some AWS SDKs would fall back to Should we add a log message when neither
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. e.g.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As suggested by @gibber9809 , this behavior is followed by generate_s3_url in s3_utils.py so that CLP package always make consistent assumption. I am okay with adding the log message when neither 'endpoint_url' nor 'region_code' is specified in S3 config as a warnning. But should we keep the same behavior as the changes in this PR? And thanks for the insight on this S3 support!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's see what @gibber9809 decides on
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for slow response. Yeah logging a warning in this case sounds reasonable. It probably also makes sense to log the same warning during the package startup whenever 'endpoint_url' and 'region_code' are missing from the package config for the same reason.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would be fine tackling this in a separate PR though that adds the warning both here and in the package startup script.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai we will merge the current PR first and add the warning messages later. let's create an issue about adding a warning message both here and in the package startup script
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 42
🧬 Code Graph Analysis Results<no_relevant_code_snippets> </no_relevant_code_snippets> 🧠 Learnings used |
||
| return f"https://{bucket_name}.s3.{AWS_ENDPOINT}/" | ||
|
20001020ycx marked this conversation as resolved.
Resolved
|
||
| return f"https://{bucket_name}.s3.{region_code}.{AWS_ENDPOINT}/" | ||
|
|
||
|
|
||
| def _add_memory_env_vars(env_vars: dict[str, str]) -> bool: | ||
| """ | ||
| Adds memory-related environment variables based on Presto guidelines. | ||
|
|
@@ -359,6 +382,7 @@ def _generate_worker_clp_properties( | |
| "clp.storage-type": "PRESTO_WORKER_CLPPROPERTIES_STORAGE_TYPE", | ||
| "clp.s3-auth-provider": "PRESTO_WORKER_CLPPROPERTIES_S3_AUTH_PROVIDER", | ||
| "clp.s3-access-key-id": "PRESTO_WORKER_CLPPROPERTIES_S3_ACCESS_KEY_ID", | ||
| "clp.s3-bucket": "PRESTO_WORKER_CLPPROPERTIES_S3_BUCKET", | ||
| "clp.s3-end-point": "PRESTO_WORKER_CLPPROPERTIES_S3_END_POINT", | ||
| "clp.s3-secret-access-key": "PRESTO_WORKER_CLPPROPERTIES_S3_SECRET_ACCESS_KEY", | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.