Repository navigation
Feature/s3 session token - #57850
Feature/s3 session token#57850
Conversation
|
This is an automated comment for commit 5f38e1d with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page Successful checks
|
|
We should add a test for each new signatures with |
4fb76af to
4c29544
Compare
This sets the infrastructure of loading session_token and passing it directly to all AWSCredentials instances that are created using the AuthSettings. The default SESSION_TOKEN is set to an empty string as documented in AWS SDK reference: https://sdk.amazonaws.com/cpp/api/0.12.9/d4/d27/class_aws_1_1_auth_1_1_a_w_s_credentials.html
4c29544 to
8aa9c8f
Compare
Hi, Thanks for the review, I think I did everything except the tests 😄 , I didn't manage to run them locally, is there a guide somewhere so I can try to test that locally, even testing that a faulty edit: I've checked and it seems that MinIO doesn't support setting a session_token, these are all the environment variables that can be set in order to set the root credentials |
Yes, even if MinIO doesn't support session_token, we should at least check that all new signatures with session_token works |
|
Any chance this works on Mac OS too?
👍 Will do. |
Don't know, sorry. You can try, if you will have any problems, you can share them here, I will ask my colleagues |
I'm getting the following error:
Note:
➜ ./runner --binary ../../build/programs/clickhouse --base-configs-dir ../../build/programs/server/ --odbc-bridge-binary ../../build/programs/CTestTestfile.cmake 'test_storage_s3 -ss'
2023-12-18 16:21:50,037 [ 42429 ] INFO : ClickHouse root is not set. Will use /Users/shanielharrar/Documents/GitHub/ClickHouse (runner:42, check_args_and_update_paths)
2023-12-18 16:21:50,037 [ 42429 ] INFO : Cases dir is not set. Will use /Users/shanielharrar/Documents/GitHub/ClickHouse/tests/integration (runner:90, check_args_and_update_paths)
2023-12-18 16:21:50,037 [ 42429 ] INFO : utils dir is not set. Will use /Users/shanielharrar/Documents/GitHub/ClickHouse/utils (runner:101, check_args_and_update_paths)
2023-12-18 16:21:50,037 [ 42429 ] INFO : base_configs_dir: /Users/shanielharrar/Documents/GitHub/ClickHouse/build/programs/server, binary: /Users/shanielharrar/Documents/GitHub/ClickHouse/build/programs/clickhouse, cases_dir: /Users/shanielharrar/Documents/GitHub/ClickHouse/tests/integration (runner:103, check_args_and_update_paths)
clickhouse_integration_tests_volume
Running pytest container as: 'docker run --net=host -it --rm --name clickhouse_integration_tests_tknz6q --platform linux/amd64 --privileged --dns-search='.' --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/build/programs/CTestTestfile.cmake:/clickhouse-odbc-bridge --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/build/programs/clickhouse:/clickhouse --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/build/programs/clickhouse-library-bridge:/clickhouse-library-bridge --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/build/programs/server:/clickhouse-config --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/tests/integration:/ClickHouse/tests/integration --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/utils/backupview:/ClickHouse/utils/backupview --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/utils/grpc-client/pb2:/ClickHouse/utils/grpc-client/pb2 --volume=/run:/run/host:ro --volume=clickhouse_integration_tests_volume:/var/lib/docker -e DOCKER_CLIENT_TIMEOUT=300 -e COMPOSE_HTTP_TIMEOUT=600 -e PYTHONUNBUFFERED=1 -e PYTEST_ADDOPTS=" 'test_storage_s3 -ss' -vvv" clickhouse/integration-tests-runner:latest '.
Can't start docker daemon, timeout exceeded.
Traceback (most recent call last):
File "/Users/shanielharrar/Documents/GitHub/ClickHouse/tests/integration/./runner", line 461, in <module>
subprocess.check_call(cmd, shell=True)
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 413, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'docker run --net=host -it --rm --name clickhouse_integration_tests_tknz6q --platform linux/amd64 --privileged --dns-search='.' --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/build/programs/CTestTestfile.cmake:/clickhouse-odbc-bridge --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/build/programs/clickhouse:/clickhouse --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/build/programs/clickhouse-library-bridge:/clickhouse-library-bridge --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/build/programs/server:/clickhouse-config --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/tests/integration:/ClickHouse/tests/integration --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/utils/backupview:/ClickHouse/utils/backupview --volume=/Users/shanielharrar/Documents/GitHub/ClickHouse/utils/grpc-client/pb2:/ClickHouse/utils/grpc-client/pb2 --volume=/run:/run/host:ro --volume=clickhouse_integration_tests_volume:/var/lib/docker -e DOCKER_CLIENT_TIMEOUT=300 -e COMPOSE_HTTP_TIMEOUT=600 -e PYTHONUNBUFFERED=1 -e PYTEST_ADDOPTS=" 'test_storage_s3 -ss' -vvv" clickhouse/integration-tests-runner:latesEdit: Anyway, I'm pushing the tests, it might run on the CI (?) |
This can help users that want to pass temporary credentials that issued by AWS in order to load data from S3 without changing configuration or creating an IAM User. Fixes ClickHouse#57848
1b051d9 to
afe6ff6
Compare
|
Ok @Avogar Seems like I forgot to change the number of arguments validation, so I just fixed it and I hope the CI is going to pass, I'll be happy if you can take a look at it today. Thank you. edit: One more fix to |
afe6ff6 to
5f38e1d
Compare
|
Despite, session_token is being pushed to ClickHouse/src/Storages/StorageS3.cpp Line 1434 in 63b4457 However it should, there is separate overload of function for temporary creds with session_token: So, s3 table function doesn't work with session_token currently. |
|
Do a workaround exist to use session_token? |
|
You can pass them as enviromental variable, so aws sdk directly consume it from here |
I passed the variables in this way: and copied the s3.xml to /opt/bitnami/clickhouse/etc/conf.d
I get this error message:
|
…py engine (#7353) # Description `ObjectStorageType` reports `S3` whenever `useRudderStorage` is set, so `UseS3CopyEngineForLoading` engaged and `credentials()` then read `accessKeyID` / `accessKey` off the destination config — which describes the customer's bucket, not Rudder's. They came back empty and were interpolated into the `s3` table function as `''`, which the server rejects as an access error that says nothing about where the keys should have come from. ### Rudder storage is not the only destination without keys | destination shape | holds keys in config? | | --- | --- | | rudder storage (`useRudderStorage`) | no — Rudder's bucket, reached via the SDK credential chain | | role-based (`iamRoleARN`) | no | | shared copy user (neither keys nor role) | no — keys live in the server's env, see `misc.GetObjectStorageConfig` | | static keys | yes | All three keyless shapes authenticate through the AWS SDK credential chain, which the `s3` table function cannot use because it only takes literals. ### The fix Mint the literals instead of enumerating which shape the destination is. `whutils.GetTemporaryS3Cred` already covers every one of them, and `redshift`, `snowflake` and `deltalake` all build their copy credentials from it unconditionally for exactly this reason: ```go case warehouseutils.S3: accessKeyID, secretAccessKey, sessionToken, err = ch.TemporaryS3Cred(&ch.Warehouse.Destination) ``` ClickHouse can do the same because the `s3` table function has taken a session token as its **fourth positional argument since 24.1** ([ClickHouse/ClickHouse#57850](ClickHouse/ClickHouse#57850)): ``` s3(url, access_key_id, secret_access_key, session_token, format, structure, compression_method) ``` So the copy engine stays available to every aws destination rather than falling back to downloading each load file — which is the larger win, since that engine is the fastest path we have. ### Compatibility - The token is **omitted from the statement when there is none**, so minio and any static-key path send the six arguments they always sent. Nothing regresses on a server older than 24.1. - v1 keeps skipping the engine for rudder storage: it has no temporary-credential path and runs against ClickHouse 21, which predates the argument entirely. - The query-log mask (`s3CredentialsRegex`) widens to cover a third credential argument. ### Behaviour change worth noting A **static-key** S3 destination now also goes through STS, so it needs `sts:GetSessionToken` on the IAM user, and the statement carries a credential that expires after `Warehouse.awsCredsExpiryInS` (1h default) rather than the customer's long-term secret. That is the same trade redshift, snowflake and deltalake already make. ### Tests - Unit: four destination shapes — rudder storage, role, no credentials at all, static keys — all asserted to reach the same mint call; minio asserted never to. - Integration: a new `Load Table round trip` case reaches the same minio bucket as an **aws** destination, minting from **minio's own STS**, so the session token the statement carries is one the bucket actually validates end to end. ## Linear Ticket https://linear.app/rudderstack/issue/INT-7100/crew-workspace-loading-is-taking-lot-of-time ## Security - [ ] The code changed/added as part of this pull request won't create any security issues with how the software is being used.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Allow passing optional SESSION_TOKEN to
s3table functionDocumentation entry for user-facing changes